# 方法1 import subprocess pSP = subprocess.Popen("ls -al", stderr=subprocess.STDOUT, stdout=subprocess.PIPE. shell=True, preexec_fn=None) # 方法2 import os os.system("ping 192.168.150.131") # 方法2 import commands (status, output) = commands.getstatusoutput("ls -al")