open file with whitespaces
bruno at modulix
onurb at xiludom.gro
Fri May 19 16:37:37 CEST 2006
> Hi guys.
> I've a very big big big problem:
I think a lot of people in the world would not find it so big wrt/ their
> I've in my windows computer a file named cicciobello.html, located in
> c:\documents and settings\username\desktop\cicciobello.html.
> Now, I MUST open this file with os.spawn(os.P_WAIT ...., because I must
> wait the user cancel the explorer window, ok?
> And so, I write:
> import os
> os.spawnl(os.P_WAIT, "c:\programmi\internet explorer\iexplorer.exe",
> "c:\documents and settings\username\desktop\cicciobello.html")
take care of the meaning of the antislash in strings... What do you
thing "c:\toto" or "c:\nothing" will expand to ?-)
Or at least, and IIRC, "c:/something/" should work.
> the python process don't fail, but explorer don't visualize correctly
> the file opened: i receive an "not found" error message.
> I've found that the whitespaces in file path are the problem.
> If you see to explorer address bar, you will find the address
> completely wrong...
Not using Windows, I won't find anything. So what's the result ?-)
Anyway, you may find urllib.urlencode useful for, well, encoding urls...
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"
More information about the Python-list