file:///home/ashu/Music/Collections/randomPicks/ipod%20on%20sep%2009/Coldplay-Sparks.mp3
How can I convert a string like the above to get the normal file path which I can pass to open()
function?
Have a look at url2pathname
:
import urllib2
path = urllib2.url2pathname("file:///home/ashu/Music/Collections/randomPicks/ipod%20on%20sep%2009/Coldplay-Sparks.mp3")
This is called unquote. Avaiable from urllib.
import urllib
urllib.unquote('%20')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With