Running command lines within your Python script

前端 未结 4 823
予麋鹿
予麋鹿 2021-02-05 08:02

So I have a bunch of aliases and Command Line prompt programs, and my main program works by inputting b into the cmd.exe, followed by some filepath names and what not. How would

4条回答
  •  無奈伤痛
    2021-02-05 08:41

    You can do this using subprocess

    For example, this call bellow gets the output of the program and stores it as a string, using .call will help with calling it and for more accurate control use .Popen

    subprocess.check_output(["ipconfig"])
    

提交回复
热议问题