方法1: 将shell执行的结果保存到字符串
def run_cmd(cmd):
result_str=''
process = subprocess.Popen(cmd, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
result_f = process.stdout
error_f = process.stderr
errors = error_f.read()
if errors: pass
result_str = result_f.read().strip()
if result_f: