- 等待,输出界面相关
import os
import subprocess
from subprocess import Popen, PIPE, STDOUT,DEVNULL
# res = os.system('ping 127.0.0.1') #主程序等待,返回0,界面输出
# res = os.system('ping 1.0.0.2') #主程序等待,返回1,界面输出
# res = subprocess.call('ping 1.0.0.2',shell=False) #主程序等待,返回1,界面输出
res = subprocess.call('ping 1.0.0.2',stdout=DEVNULL, stderr=subprocess.STDOUT,shell=False) #主程序等待,返回1,打印界面隐藏
# res = subprocess.Popen('ping 127.0.0.1') # 主程序不等待
# res = subprocess.Popen('ping 127.0.0.1', stdout=DEVNULL, stderr=subprocess.STDOUT) # 主程序不等待
print(res)