运维网's Archiver
论坛
›
Python
› python 获取shell命令返回值
小风儿
发表于 2017-5-4 11:18:35
python 获取shell命令返回值
1.os.system(cmd) 只能得到成功或者失败信息。
2.os.popen 或者os.popen2()
3.output = subprocess.Popen(['ls','-l'],stdout=subprocess.PIPE,shell=True).commun icate()
4. command 模块 status, output = commands.getstatusoutput('ls -l')
页:
[1]
查看完整版本:
python 获取shell命令返回值