subprocess.Popen spaces within system property arg
将命令作为列表传递时,subprocess.Popen 将自动引用有空格的参数。但是,如果我使用具有如下空格的系统属性运行 java:
1
|
-Dwebdriver.firefox.bin="C://Program Files (x86)//Mozilla Developer Preview//firefox.exe"
|
,会报错:
‘C:////Program’ 无法识别错误
,我认为这是因为 Popen 会在看到空格时在整个参数周围插入引号,并转义其余的双引号。如果我想继续使用 Popen 命令,我不确定如何解决这个问题:
1
2 3 4 |
subprocess.Popen([
‘cmd.exe’, ‘/C’, ‘C:////Program Files////java////jre7////bin////java.exe’, ‘-Dwebdriver.firefox.bin="C:////Program Files (x86)////Mozilla Developer Preview////firefox.exe"’, ‘-jar’, ‘C:////Users////testing////Temp////SeleniumServer.jar’]) |
将该参数作为一个不带引号的列表项提供
1
|
[…, ‘-Dwebdriver.firefox.bin=C:////Program Files (x86)////Mozilla Developer Preview////firefox.exe’, …]
|
它应该可以正常工作
引号只需要告诉命令行将其作为一个参数,但列表已经为你做了,所以引号只是在
看看这个答案:ffmpeg through python subprocess failed to find camera
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/python/267943.html