转自:http://blog.youkuaiyun.com/laiahu/article/details/6697930
python中执行linux命令:
os.system(cmd)
如果要把返回信息置入变量中:
textlist = os.popen(cmd)
例:
cmd = 'ps -ef '
textlist = os.popen(cmd).readlines()
for line in textlist:
......
更多:https://blog.youkuaiyun.com/shanliangliuxing/article/details/8811701
本文介绍如何使用Python执行Linux命令并获取其输出。通过os模块的system和popen方法,可以轻松实现这一目标。前者用于执行命令,后者则能将命令的输出读取到变量中。
297

被折叠的 条评论
为什么被折叠?



