如何避免带有包含 os.system 调用的 .pyw 文件的控制台窗口?
- 作者: 武得
- 来源: 51数据库
- 2022-11-15
问题描述
如果我将代码文件保存为 .pyw,则不会出现控制台窗口 - 这是我想要的 - 但如果代码包含对 os.system 的调用,我仍然得到一个讨厌的控制台窗口.我认为这是由对 os.system 的调用引起的.有没有办法从我的 .pyw 脚本中执行其他文件而根本不提升控制台窗口?
If I save my code files as .pyw, no console window appears - which is what I want - but if the code includes a call to os.system, I still get a pesky console window. I assume it's caused by the call to os.system. Is there a way to execute other files from within my .pyw script without raising the console window at all?
推荐答案
你可以尝试使用 subprocess 模块(subprocess.Popen、subprocess.call 或其他),如果您想避免启动,请使用参数 shell=True一个控制台窗口.
You could try using the subprocess module (subprocess.Popen, subprocess.call or whatever) with the argument shell=True if you want to avoid starting a console window.
推荐阅读
热点文章
Discord.py(重写)on_member_update 无法正常工作
0
Discord.py 在 vc 中获取用户分钟数
0
discord.py 重写 |为我的命令出错
0
Discord.py rewrite 如何 DM 命令?
0
播放音频时,最后一部分被切断.如何解决这个问题?(discord.py)
0
在消息删除消息 Discord.py
0
如何使 discord.py 机器人私人/直接消息不是作者的人?
0
(Discord.py) 如何获取整个嵌入内容?
0
Discord bot 尽管获得了许可,但不能提及所有人
0
Discord.py discord.NotFound 异常
0
