因此,我在Scala中发送以下系统命令:
val command = "python other/evaluateAnswers.py 'chemistry earth' 'the chemistry of the world in champaign' 'the chemistry of the computer science world'"命令。!!
以下是我的python代码的简化版本:
def main(argv):
# example run:
print(argv)
# do stuff here ...
if __name__ == '__main__':
main(sys.argv[1:])如果我直接在终端内部运行这个命令:
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'"]这是不正确的拆分。
你知道我哪里错了吗?
发布于 2017-01-11 02:50:29
手动分割我的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.!!https://stackoverflow.com/questions/41575841
复制相似问题