skywind3000/PyStand

subprocess 执行会弹控制台

Closed this issue · 1 comments

wuwao1 commented

PyStand.int添加如下代码,会弹控制台, 有没有大佬知道怎么不弹控制台

import sys, os
os.chdir(os.path.dirname(__file__))
sys.path.append(os.path.abspath('script'))
import subprocess
def runcmd(command):
    while 1:
        ret = subprocess.run(command,stdout=subprocess.PIPE,stderr=subprocess.PIPE,encoding="utf-8",timeout=3)
        if ret.returncode == 0:
            print("success:",ret)
        else:
            print("error:",ret)
            
runcmd(["ping","www.baidu.com"]) 

image

wuwao1 commented

加shell=True OK了