gpt4 book ai didi

python - 在Python中使用os.system()打开一个程序,看不到启动程序的窗口

转载 作者:太空宇宙 更新时间:2023-11-03 16:17:54 25 4
gpt4 key购买 nike

我正在尝试从 python 代码中启动程序/GUI。

在终端中,我只需输入程序名称即可启动该程序。几行输出到终端,然后打开一个带有 GUI 的单独窗口。

我尝试通过运行在 python 中模拟这个

os.system("<program name>")

如上所述,典型的输出行会打印到控制台,但 GUI 不会打开任何窗口。

os.system()可以用来执行有自己独立窗口的程序吗?

最佳答案

来自Python manual :

[os.system] is implemented by calling the Standard C function system()

话虽如此,使用 os.system 启动 GUI 应用程序应该不会有任何问题。 。我刚刚亲自尝试过,效果很好。

手册中还提到:

The subprocess module provides more powerful facilities for spawning new processes and retrieving their results; using that module is preferable to using this function.

也许这值得一试。当您使用 os.system 生成任何其他 GUI 应用程序时,它们是否可以工作? ?

关于python - 在Python中使用os.system()打开一个程序,看不到启动程序的窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38753553/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com