首页 > TAG信息列表 > subp

python执行shell命令

import subprocessdef cmd(command): subp = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8") return subp.communicate()res = cmd("ls -l")res = res[0]res = res.split("\n&qu