2016-06-12 120 views

回答

0

可以使用subprocess.call

subprocess.call(args, *, stdin=None, stdout=None, stderr=None, shell=False) 

这里*是BUFSIZE做到这一点,0表示无缓冲,1表示行缓冲,任何其他正值表示使用大约该大小的缓冲器。 bufsize的默认值是0(无缓冲)。

示例(从文档) -

from subprocess import call 
subprocess.call(["ls", "-l"]) 

来源 - https://docs.python.org/2/library/subprocess.html

+0

我已经阅读过这个答案,以及你可以只写出确切的路线?我的意思是上面提到的cmd指令! Ps什么是*? –

+0

如果有多个命令,然后在列表中将它们分开,'subprocess.call(“your command”,shell = True)'...我无法测试它,因为我使用基于Unix的系统。我也编辑了答案。 – hashcode55

+0

谢谢@ hashcode55!这是工作。我正在寻找这个简短的答案 - > subprocess.call(“你的命令”,shell = True) –