#encoding=utf8
from subprocess import Popen, PIPE, STDOUT
import os
currentPath = os.path.dirname(os.path.realpath(__file__))
command ="echo 'hello linux world!'"
p = Popen(command,shell=True,stdin=PIPE,stdout=PIPE,stderr=STDOUT,close_fds=True,cwd=currentPath)
output, errors = p.communicate()
if errors:
print(errors)
print(output)
python执行shell指令Popen方法
最新推荐文章于 2024-09-28 08:00:00 发布