run
>>> import subprocess >>> subprocess.run("ifconfig")
2.call
>>> subprocess.call("df -h",shell=True)
3.Popen
>>> a = subprocess.Popen("df -h",shell=True,stdout=subprocess.PIPE) >>> a.stdout.read() ‘Filesystem Size Used Avail Use% Mounted on\n/dev/mapper/vg0-root 270G 189G 67G 74% /\ntmpfs 7.8G 20K 7.8G 1% /dev/shm\n/dev/sda1 194M 27M 157M 15% /boot\n‘
本文出自 “AMY” 博客,请务必保留此出处http://amy2015.blog.51cto.com/11407620/1772387
原文地址:http://amy2015.blog.51cto.com/11407620/1772387