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