有 os.system() 或 subprocess.call() 没有返回或错误

问题描述 投票:0回答:1

我想要一种 os.system() 或 subprocess.call() 不在终端中返回任何文本的方法。

我想让代码在后台运行,每当应用程序打开时就会关闭它,而且我已经把它关闭了

def x():
    os.system("code here")
    subprocess.call("code here")
x()

会回来...

(code here) was executed successfully

无论如何,我如何防止它返回错误或输出?我让它在后台使用 threading 运行,但无论如何都没有什么区别。

我已经尝试了this问题的答案,但它们要么不起作用,要么仍然显示输出。由于它是公司计算机,我能做的事情稍微受到限制。

python return
1个回答
0
投票

由于您想在后台运行代码,您可以对其进行守护进程,例如使用此库:python-daemon

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.