How do I execute a program from Python? os.system fails due to spaces in path

后端 未结 10 986
一生所求
一生所求 2020-11-22 08:19

I have a Python script that needs to execute an external program, but for some reason fails.

If I have the following script:

import os;
os.system(\"C         


        
10条回答
  •  [愿得一人]
    2020-11-22 08:56

    No need for sub-process, It can be simply achieved by

    GitPath="C:\\Program Files\\Git\\git-bash.exe"# Application File Path in mycase its GITBASH
    os.startfile(GitPath)
    

提交回复
热议问题