gpt4 book ai didi

python - R代码中的命令行

转载 作者:太空宇宙 更新时间:2023-11-03 23:49:07 26 4
gpt4 key购买 nike

首先让我说我是编程新手。

我希望在 R 脚本中从命令行运行 python 脚本。我正在运行 Windows xp,但也有一台运行 Windows 7 的机器。我可以在 dos 提示符下运行以下代码而不会出错。

cd C:\Documents and Settings\USER\workspace\UGA - Website
python test1.py

我在 R 中使用 ?system 尝试过各种不同的尝试,但我希望有人能指出我做错了什么。比如这里只是一个尝试(推荐使用绝对路径)

cmd.1 <- shQuote("C:Python26/python.exe C:/Documents and Settings/USER/Desktop/UGA New Website", type="cmd")
system(cmd.1)

非常感谢任何指导

最佳答案

感谢大家的帮助。我的问题是多种因素的结合,但这段代码有效。

shell(paste("python", shQuote("C:\\Documents and Settings\\USER\\Desktop\\UGA New Website\\metrics_get.py")))

非常感谢

关于python - R代码中的命令行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3284301/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com