我试过了
a = subprocess.run(['apt download timeshhhh'],stdout = subprocess.PIPE, shell = True)
但这表明:
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
E: Unable to locate package timeshhhh
我只想要:
E: Unable to locate package timeshhhh
怎么办?
最佳答案
那是 stderr
输出,您没有重定向它。如果您不想看到它,可以将其重定向到 DEVNULL
。
a = subprocess.run(['apt download timeshhhh'],stdout = subprocess.PIPE, stderr = subprocess.DEVNULL, shell = True)
关于python - 运行终端命令但不通过 python 显示输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54136784/