Running a batch file with parameters in Python OR F#

前端 未结 3 1989
旧巷少年郎
旧巷少年郎 2021-01-13 18:38

I searched the site, but I didn\'t see anything quite matching what I was looking for. I created a stand-alone application that uses a web service I created. To run the clie

3条回答
  •  太阳男子
    2021-01-13 19:31

    Python is similar.

    import os
    os.system("run-client.bat param1 param2")
    

    If you need asynchronous behavior or redirected standard streams.

    from subprocess import *
    p = Popen(['run-client.bat', param1, param2], stdout=PIPE, stderr=PIPE)
    output, errors = p.communicate()
    p.wait() # wait for process to terminate
    

提交回复
热议问题