2011-04-13 132 views
2

我是python的新手。任何想法爲什麼這不起作用:在Python中運行命令

 

C:\Python27>python 
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on 
win32 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import os 
>>> cmdBuilder = os.path.join("C:\\","Program Files","InstallShield","2011 SAB", 
"System","IsCmdBld.exe") 
>>> os.system(cmdBuilder) 
'C:\Program' is not recognized as an internal or external command, 
operable program or batch file. 
1 
>>> 
 

可執行文件確實存在。這似乎在程序和文件之間的空間將被逮住

感謝

+1

嘗試 「PROGRA〜1」,而不是 「程序文件」。 – GreenMatt 2011-04-13 17:27:03

回答

3

嘗試在引號包裹可執行文件:

>>> os.system('"'+cmdBuilder+'"') 
+0

Awsome,工作就像一個魅力。 – user489041 2011-04-13 17:27:33