如果我将代码文件保存为 .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.
这篇关于如何避免带有包含 os.system 调用的 .pyw 文件的控制台窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何在 conda 环境中安装 Selenium?How to install Selenium in a conda environment?(如何在 conda 环境中安装 Selenium?)
使用 Anaconda installe 在 Windows 上获取 CUDA 和 CUDNNget the CUDA and CUDNN version on windows with Anaconda installe(使用 Anaconda installe 在 Windows 上获取 CUDA 和 CUDNN 版本)
如何下载适用于 python 3.6 的 AnacondaHow can I download Anaconda for python 3.6(如何下载适用于 python 3.6 的 Anaconda)
使用两个不同的 Python 发行版Using two different Python Distributions(使用两个不同的 Python 发行版)
除了 OSX 上现有的 pyenv 安装之外,如何安装 AnaHow can I install Anaconda aside an existing pyenv installation on OSX?(除了 OSX 上现有的 pyenv 安装之外,如何安装 Anaconda?)
在 Cygwin 中为 Anaconda 永久设置 Python 路径Permanently set Python path for Anaconda within Cygwin(在 Cygwin 中为 Anaconda 永久设置 Python 路径)