【问题标题】:Running Commands in Python在 Python 中运行命令
【发布时间】:2011-04-13 17:23:40
【问题描述】:

我是 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 >>>

可执行文件确实存在。它似乎被 Program 和 Files 之间的空间所吸引

谢谢

【问题讨论】:

  • 尝试“progra~1”而不是“Program Files”。

标签: python command


【解决方案1】:

尝试将可执行文件用引号括起来:

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

【讨论】:

    【解决方案2】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-14
      • 1970-01-01
      • 2018-12-28
      • 1970-01-01
      • 2012-05-31
      • 1970-01-01
      • 2019-08-13
      相关资源
      最近更新 更多