subprocess run

 

python 3.5 subprocess中新增run方法很好用:

>>>a= subprocess.run("ls", stdout=subprocess.PIPE,stderr=subprocess.PIPE,encoding="utf-8")
CompletedProcess(args='ls', returncode=0, stdout=b'antest.py\\n')

a.stdout

b'antest.py\\n'

 

reference:

    https://www.cnblogs.com/zhou2019/p/10582716.html

   https://www.runoob.com/w3cnote/python3-subprocess.html

 

posted @ 2021-05-10 18:41  i舒  阅读(401)  评论(0编辑  收藏  举报