skywind3000 / PyStand

:rocket: Python Standalone Deploy Environment !!
MIT License
641 stars 75 forks source link

subprocess 执行会弹控制台 #45

Closed wuwao1 closed 1 year ago

wuwao1 commented 1 year ago

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 1 year ago

加shell=True OK了