简体   繁体   English

最小化时如何使python文件在后台运行?

[英]How to make a python file run in the background when minimized?

I made a Python program that I do NOT want to turn into .exe or anything else.我做了一个 Python 程序,我不想把它变成 .exe 或其他任何东西。
However since the program needs python.exe to run, it runs python.exe openly.但是由于该程序需要python.exe才能运行,因此它公开运行python.exe。
I want to know if I can add a piece of code to the program I made so that it runs in the background.我想知道我是否可以在我制作的程序中添加一段代码,以便它在后台运行。
BTW, I do not want to run through cmd.I want it to be a background process automatically.顺便说一句,我不想​​通过 cmd.I 运行。我希望它自动成为后台进程。
Basically, I want to add some code into my program so that as soon as it is clicked upon, it runs in background.基本上,我想在我的程序中添加一些代码,以便一旦点击它,它就会在后台运行。

I found out the way to do this easily: I just renamed my file.py into file.pyw我找到了轻松做到这一点的方法:我刚刚将我的 file.py 重命名为 file.pyw
Now, it runs without a console.现在,它无需控制台即可运行。 Basically I typed this in the cmd:基本上我在cmd中输入了这个:
ren file.py file.pyw

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM