现在的位置: 首页 > 综合 > 正文

(转)python中执行linux命令

2013年02月22日 ⁄ 综合 ⁄ 共 149字 ⁄ 字号 评论关闭

 

python中执行linux命令:

os.system(cmd)

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

textlist = os.popen(cmd)

例:

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

抱歉!评论已关闭.