import subprocess
#最基本的启动进程方式类似cmd下执行: notepad.exe text.txt 命令
obj = subprocess.Popen(['notepad.exe','text.txt'], shell = True, stdin=subprocess.PIPE, stdout=subprocess.PIPE ,stderr=subprocess.PIPE)
print(obj.stderr.read().decode('gbk'))
#进入某个环境执行语句,需要依赖上次执行的状态
obj = subprocess.Popen('python', shell = True, stdin=subprocess.PIPE, stdout=subprocess.PIPE ,stderr=subprocess
python之subprocess.Popen常用案例
最新推荐文章于 2025-07-08 10:38:57 发布
