- 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‘
时间: 2024-11-05 02:31:19