下面的代码在Python 3.0中已过时,替换为subprocess.getstatusoutput()
。
import commands
(ret, out) = commands.getstatusoutput('some command')
print ret
print out
真正的问题是,对于Python中的这个命令,多平台的替代方案是什么,因为上面的代码在Windows下确实很难看,因为getstatusoutput只在Unix下受支持,Python没有告诉您这一点,相反,您会得到如下结果:
>test.py
1
'{' is not recognized as an internal or external command,
operable program or batch file.
目前没有回答
相关问题 更多 >
编程相关推荐