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

后端 未结 10 988
一生所求
一生所求 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:52

    I suspect it's the same problem as when you use shortcuts in Windows... Try this:

    import os;
    os.system("\"C:\\Temp\\a b c\\Notepad.exe\" C:\\test.txt");
    

提交回复
热议问题