永夜海 发表于 2018-8-14 09:21:51

python之执行shell命令

# python  
Python 2.7.5 (default, Sep 15 2016, 22:37:39)
  
on linux2
  
Type "help", "copyright", "credits" or "license" for more information.
  
>>> import os          #加载模块
  
>>> r=os.system
  
>>> r("ls /root")      #执行命令
  
anaconda-ks.cfgMusic
  
ceph-release-1-1.el7.noarch.rpm   Pictures
  
DesktopPublic
  
DocumentsTemplates
  
DownloadsVideos
  
epel-release-latest-7.noarch.rpmwin_2008.qcow2
  
initial-setup-ks.cfgzabbix-agent-3.0.5-1.el7.x86_64.rpm
  
0
页: [1]
查看完整版本: python之执行shell命令