1. 程式人生 > >python之執行shell命令

python之執行shell命令

python

[[email protected] ~]# python
Python 2.7.5 (default, Sep 15 2016, 22:37:39) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os          #加載模塊
>>> r=os.system
>>> r("ls /root")      #執行命令
anaconda-ks.cfg			  Music
ceph-release-1-1.el7.noarch.rpm   Pictures
Desktop				  Public
Documents			  Templates
Downloads			  Videos
epel-release-latest-7.noarch.rpm  win_2008.qcow2
initial-setup-ks.cfg		  zabbix-agent-3.0.5-1.el7.x86_64.rpm
0


本文出自 “學習筆記” 博客,請務必保留此出處http://quliren.blog.51cto.com/9849266/1942725

python之執行shell命令