【发布时间】:2015-02-24 02:02:21
【问题描述】:
我想用 os.system 运行命令,但出现错误
c:/fe ' is not recognized as an internal or external command, operable program or batch file
我使用的代码是
import os
os.system('"C:\\fe re\\python.exe" program "c:\\test now\\test.txt" http://site.to.explore')
如果我只运行它就会起作用:
import os
os.system('"C:\\fe re\\python.exe" program -h')
或者如果我在 python 路径中没有这样的空间
import os
os.system('C:\\fere\\python.exe program "c:\\test now\\test.txt" http://site.to.explore')
但是如果我在 python 路径和 txt 路径中的命令中都有两对双引号,我会收到一个错误...
【问题讨论】:
-
怎么样:
os.system('""C:\\fe re\\python.exe" program "c:\\test now\\test.txt" http://site.to.explore"')? -
啊……太好了……谢谢……
标签: python windows python-2.7 os.system