鸿蒙之紫莲圣人,android源码下载,北京罗马阳光酒店
1 import subprocess 2 def exec_command(cmd, log_path, **kwargs): 3 with open(log_path, 'w') as f: 4 p = subprocess.popen(cmd, 5 shell=true, 6 stdout=f.fileno(), 7 stderr=f.fileno(), 8 executable='/bin/bash', 9 **kwargs) 10 p.communicate() #立即阻塞父进程,直到子进程结束 11 if p.returncode != 0: 12 print('cmd: %s execute failed', cmd) 13 else: 14 print('execute command: %s finished', cmd) 15 return p.returncode
详细介绍subprocess模块:https://www.cnblogs.com/security-darren/p/4733368.html
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
新手学习Python2和Python3中print不同的用法
Python基于os.environ从windows获取环境变量
网友评论