windows下调用脚本,主程序关闭,禁止子进程关闭

主脚本运行通过
subprocess.Popen([‘python’,’D:\sheiruan\python\Project\c.py’] )
或者
os.system(‘python D:\sheiruan\python\Project\c.py’)
运行,主脚本退出了,但是调用的脚本也会退出
怎么才能不退出?

讨论数量: 2

= =#研究了好几天,终于找到个方案
os.system(‘start python D:\sheiruan\python\Project\c.py’)
不过好像不能获取到运行进程的pid

3年前 评论

p=subprocess.Popen(['python.exe','D:\sheiruan\python\Project\c.py'],creationflags=0x08000000) print(p.pid) 找到个完美解决方法,

3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!