我想用R执行python但是
> system2('python2', args = c('-c', 'print', 'hello'), stdout = TRUE)
[1] ""
使用python2打印""
而不是hello
。
然后再次
> system2('python3', args = c('-c', 'print("hello")'), stdout = TRUE, stderr = TRUE)
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `'python3' -c print("hello") 2>&1'
character(0)
attr(,"status")
[1] 2
Warning message:
running command ''python3' -c print("hello") 2>&1' had status 2
打印了很多警告。目标输出为hello
。
如何使用system2在R里面用python2 / python3打印你好?