I have a file with the following path :

D:/bar/クレイジー・ヒッツ!/foo.abc

I am parsing the path from a XML file and storing it in a variable called "path" in the form of "file://localhost/D:/bar/クレイジー・ヒッツ!/foo.abc"
Then, the following operations are being done :

path=path[17:]  #to remove the file://localhost/   part from the path
            path=urllib.url2pathname(path)
            path=path.decode('utf8') '''to properly encode the path in case it has non-english characters'''

Now, when I run this code, I get the following error

IOError: [Errno 2] No such file or directory: u'D:\\Music\\Pink Floyd\\The Wall Disc 1\\5 - Another Brick in the Wall, Pt. 2.mp3'

I am using Python 2.7 on Windows 7

Spaces in folder and file names create problems with Windows ...

# the Microsoft kludge, quoting a string within a string fixes the 
# space-in-folder-name problem, tells the OS to use the whole string
# including spaces as a single command
# (make sure filename does not contain any spaces!)
path = '"C:/Program Files/IrfanView/i_view32.exe" ' + filename
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.