如果可能的话,我想在R中打印Python代码的结果(不需要分配给变量)。
以下方法可以实现:
我希望这能够正常工作:
以下方法可以实现:
library(reticualte)
py_run_string("print(2)")
2
这是有效的:
p = py_run_string("x = 2")
p$x
2
我希望这能够正常工作:
py_run_string("2")
2
背景:
我希望能够阅读完整的Python代码,并在不使用(print)的情况下捕获输出。
如果我在Python3.7 Shell中只执行"2"作为命令,输出将为"2"。这里是空的。
Github请求链接:https://github.com/rstudio/reticulate/issues/595。