[英]run terminal command but don't show output via python
I tried this 我试过了
a = subprocess.run(['apt download timeshhhh'],stdout = subprocess.PIPE, shell = True)
but this shows: 但这表明:
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
E: Unable to locate package timeshhhh
I want only: 我只想要:
E: Unable to locate package timeshhhh
what to do? 该怎么办?
That's the stderr
output, which you didn't redirect. 这是stderr
输出,您没有重定向。 You can redirect it to DEVNULL
if you don't want to see it. 如果不想看到它,可以将其重定向到DEVNULL
。
a = subprocess.run(['apt download timeshhhh'],stdout = subprocess.PIPE, stderr = subprocess.DEVNULL, shell = True)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.