fahad
fahad

Reputation: 3179

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?

Upvotes: 1

Views: 21959

Answers (1)

Sachin Gupta
Sachin Gupta

Reputation: 8358

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)

Upvotes: 11

Related Questions