Scala:带参数的python脚本的系统命令

2024-05-16 15:22:22 发布

您现在位置:Python中文网/ 问答频道 /正文

所以我用Scala发送这个系统命令:

val command = "python other/evaluateAnswers.py 'chemistry earth' 'the chemistry of the world in champaign' 'the chemistry of the computer science world'"

命令。!!在

下面是我的python代码的简化版本:

^{pr2}$

如果我直接在终端内运行:

daniel$ python other/evaluateAnswers.py 'chemistry earth' 'the chemistry of the world in champaign' 'the chemistry of the computer science world'

以下是我的python代码中print(argv)的结果:

['chemistry earth', 'the chemistry of the world in champaign', 'the chemistry of the computer science world']

这是正确的。在

如果我通过command.!!从scala运行这个,我会在print(argv)的输出中得到以下结果:

["'chemistry", "earth'", "'the", 'chemistry', 'of', 'the', 'world', 'in', "champaign'", "'the", 'chemistry', 'of', 'the', 'computer', 'science', "world'"]

这是不正确的分割。在

你知道我哪里出错了吗?在


Tags: ofthe代码inpyworldcommandcomputer
1条回答
网友
1楼 · 发布于 2024-05-16 15:22:22

手动拆分scala命令实现了以下目的:

val command = Seq("python", "other/evaluateAnswers.py", "'chemistry earth'", "'the chemistry of the world in champaign'", "'the chemistry of the computer science world'")
command.!!

相关问题 更多 >