How to run dos commands in python?

This question already has an answer here:

  • Calling an external command in Python 50 answers

  • import subprocess
    ch=subprocess.Popen("megarec.exe -cleanflash .1",shell=True,stdout=subprocess.PIPE,stderr=subrocess.PIPE)
    output,err=ch.communicate()
    if output:
         print "success:",output
    else:
         print "error:",error
    
    链接地址: http://www.djcxy.com/p/13502.html

    上一篇: 如何从python提供命令行命令?

    下一篇: 如何在python中运行dos命令?