简体   繁体   中英

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. You can redirect it to DEVNULL if you don't want to see it.

a = subprocess.run(['apt download timeshhhh'],stdout = subprocess.PIPE, stderr = subprocess.DEVNULL, shell = True)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM