url encoding - Encode file path properly using python -


i trying open files getting path dictionary. of file names have commas (,) , other such characters when used give "no such file found error"

for instance following file path not open: foo,%20bar.mp3

if characters commas exist should encoded : foo%2c%20bar.mp3

can tell me how this?

you may need pathname2url

python 2.x (docs)

>>> urllib import pathname2url  >>> pathname2url('foo, bar.mp3') 'foo%2c%20bar.mp3' 

python 3.x (docs)

>>> urllib.request import pathname2url >>> pathname2url('foo, bar.mp3') 'foo%2c%20bar.mp3' 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -