美文网首页
python调用外部命令

python调用外部命令

作者: bigtom | 来源:发表于2016-09-20 11:32 被阅读49次

os.system("命令加参数")

stream = os.popen("命令和参数")

print subprocess.Popen("echo Hello World", shell=True,stdout=PIPE).stdout.read()

print os.popen("echo Hello World").read()

return_code = subprocess.call("echo Hello World", shell=True)

os模块里也有C语言里fork/exec/spawn 方法,

print subprocess.Popen("echo %s " % user_input, stdout=PIPE).stdout.read()

相关文章

网友评论

      本文标题:python调用外部命令

      本文链接:https://www.haomeiwen.com/subject/hlqoettx.html