open file with whitespaces
fredrik at pythonware.com
Fri May 19 16:55:16 CEST 2006
> Now, I MUST open this file with os.spawn(os.P_WAIT ...., because I must
> wait the user cancel the explorer window, ok?
note that backslashes in string literals have special meaning in Python; to make
sure a backslash in the string literal really ends up as a backslash in the resulting
string, you must either double each backslash, or use "raw" strings:
program = r"c:\programmi\internet explorer\iexplorer.exe"
file = r"c:\documents and settings\username\desktop\cicciobello.html"
also, getting the quoting/escaping right with os.exec/os.spawn is quite messy. I
recommend using the subprocess module instead:
print subprocess.call([program, file])
More information about the Python-list