更新:不鼓励使用
os.system,尽管在Python 3中仍然可用。
用途
os.system:
os.system(my_cmd)
如果你确实要使用子流程,请使用以下解决方案(大部分内容来自子流程的文档):
p = subprocess.Popen(my_cmd, shell=True)os.waitpid(p.pid, 0)
OTOH,你可以完全避免系统调用:
import shutilwith open('myfile', 'w') as outfile: for infile in ('file1', 'file2', 'file3'): shutil.copyfileobj(open(infile), outfile)


