[py] os.system os.popen commands 执行shell

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[py] os.system os.popen commands 执行shell相关的知识,希望对你有一定的参考价值。

?

1.仅输出到屏幕,pwd保存的是状态<=====可用于执行shell命令

pwd=os.system(pwd)

?

2.popen可以保存命令结果

pwd=os.popen(‘pwd‘).read()

?

3,返回状态和命令结果

pwd=commands.getstatusoutput(‘pwd‘)

(0, ‘/home/py‘)

以上是关于[py] os.system os.popen commands 执行shell的主要内容,如果未能解决你的问题,请参考以下文章