Search code examples
pythonpathspaceos.system

Python error for space in path


In python if I try to give path with space I'm getting error as below

import os  
os.system("C:\Program Files (x86)\(application.exe)")

'C:\Program' is not recognized as an internal or external command, operable program or batch file.

How can I give path with space?


Solution

  • You can make it working by using r.

    E.g. :

    import os
    cmd =r'"C:\Program Files (x86)\Java\jre7\bin\java.exe"'
    os.system(cmd)