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

后端 未结 10 1045
一生所求
一生所求 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 09:08

    import win32api # if active state python is installed or install pywin32 package seperately
    
    try: win32api.WinExec('NOTEPAD.exe') # Works seamlessly
    except: pass
    

提交回复
热议问题