从包含空格的参数的另一个文件中调用python文件

时间:2017-11-08 21:29:16

标签: python subprocess

如果我运行一个脚本,该脚本运行并将参数传递给另一个脚本

python = 'C:/Python27/' 
route = 'D:/core.py'
arguments = '{'a': 'apple'}'
subprocess.call('{0} {1} {2}'.format(python, route, arguments))

在core.py中,我只获得'{'a':作为参数,空格之后的所有内容都将丢失。有解决方法吗?

1 个答案:

答案 0 :(得分:0)

更改此行     争论=' {' a':' apple'}' 至     争论=" {' a':' apple'}"