python中的commands模块

commands模块用于调用shell命令

有3中方法:

commands.getstatus()   返回执行状态

commands.getoutput()   返回执行结果

commands.getstatusoutput()  返回一个元组,执行状态和执行结果

其他执行shell命令的方法还有:

1.os.system(cmd)

2.os.popen(cmd)

原文地址:https://www.cnblogs.com/liyiran/p/4223153.html