[英]How to launch python from within python Windows 10)?
I am running python3 in Windows 10. Within my program, I try to launch another python instance.我在 Windows 10 中运行 python3。在我的程序中,我尝试启动另一个 python 实例。
os.system("python -m http.server")
print("All Done")
or或者
os.system("python")
I want to see a Window shell that pops up and allow me the see the output and interact with it.我想看到一个弹出的窗口外壳,让我看到输出并与之交互。 But instead the program just continues.
但相反,程序只是继续。 I don't even see a window pops up.
我什至没有看到弹出窗口。 What am I missing?
我错过了什么?
If you want to open a new window, you need to use start cmd
如果要打开新窗口,则需要使用
start cmd
If you want to open a new window running a command from cmd, that's start cmd /c "command"
如果你想从 cmd 打开一个运行命令的新窗口,那就是
start cmd /c "command"
eg例如
import os
os.system('start cmd /c "python -m http.server"')
However, if you really just want to run another python process, you can import and run the server directly from code - refer docs但是,如果您真的只想运行另一个 python 进程,则可以直接从代码导入和运行服务器 -请参阅文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.