(转)python中执行linux命令

来源:互联网 发布:新人淘宝刷単教程 编辑:程序博客网 时间:2024/04/30 07:00
 

python中执行linux命令:

os.system(cmd)

如果要把返回信息置入变量中:

textlist = os.popen(cmd)

例:

cmd = 'ps -ef '
textlist = os.popen(cmd).readlines()
for line in textlist:
           ......


原创粉丝点击