幽灵资源网 Design By www.bzswh.com
                                1.使用os.system()去调用,但是只能返回执行状态,不能获取shell cmd执行结果
#!/usr/bin/python
# -*- coding: utf-8
import os
status = os.system("ps aux |grep Xcode |grep -v grep")
print status
2.使用os.popen执行并获取结果
"htmlcode">
#整份字符串处理
p=os.popen('ps aux |grep Xcode |grep -v grep') 
res=p.read()
print res,type(res)
p.close()
#多行处理
p=os.popen('ps aux |grep Xcode |grep -v grep') 
res1=p.readlines()
for line in res1:
  print 'line :'+line
p.close()
3.使用commands 模块commands.getstatusoutput()
"htmlcode">
import commands
status, output = commands.getstatusoutput('ps aux |grep Xcode |grep -v grep')
print output
output_list = output.splitlines()
print output_list
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
幽灵资源网 Design By www.bzswh.com
                            
                                广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
                        免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
幽灵资源网 Design By www.bzswh.com
                        暂无评论...
                                     
                        