I am trying to run a python script from another as follows, some of the arguments take quotes (")
,how do I run this command with quotes?
我试图从另一个运行python脚本如下,一些参数采用引号(“),如何使用引号运行此命令?
cmd = r"python ./clone.py -u username -rl %s -ra adar.py -d 13346612 -at "Cloning for automation" -m "Pace" -r "Cloning for automation" "%radar
proc = Popen(cmd.split(' '), stdout=PIPE, stderr=PIPE)
UPDATE#1:I tried the following suggestions but none of them worked
更新#1:我尝试了以下建议,但没有一个有效
(i)escape the quotes
(ii)Use multi line quotes
(iii)Use single quotes as delimiter
UPDATE#2:
I tried to run with shell=TRUE
but the python script hungs
我尝试使用shell = TRUE运行但python脚本挂起
2 个解决方案
#1
0
You can use single quotes ' to delimit your string and double quotes " inside the string to delimit your arguments.
您可以使用单引号'来分隔字符串,并在字符串内部使用双引号来分隔您的参数。
#2
0
Use a multi-line string
使用多行字符串
Wrap the cmd in 3 single quotes on each side:
将cmd包裹在每侧的3个单引号中:
i.e.:
cmd = '''
python ./clone.py -u username -rl {} -radar.py -d
13346612 -at "Cloning for automation" -m "Pace" -r "Cloning for
automation"
'''.format(radar)
#1
0
You can use single quotes ' to delimit your string and double quotes " inside the string to delimit your arguments.
您可以使用单引号'来分隔字符串,并在字符串内部使用双引号来分隔您的参数。
#2
0
Use a multi-line string
使用多行字符串
Wrap the cmd in 3 single quotes on each side:
将cmd包裹在每侧的3个单引号中:
i.e.:
cmd = '''
python ./clone.py -u username -rl {} -radar.py -d
13346612 -at "Cloning for automation" -m "Pace" -r "Cloning for
automation"
'''.format(radar)