How to remove% 20 from file path?

file:///home/ashu/Music/Collections/randomPicks/ipod%20on%20sep%2009/Coldplay-Sparks.mp3

How can I convert a string like the one above to get a normal file path that I can pass to a function open()?

+4
source share
2 answers

Take a look url2pathname:

import urllib2

path = urllib2.url2pathname("file:///home/ashu/Music/Collections/randomPicks/ipod%20on%20sep%2009/Coldplay-Sparks.mp3")
+16
source

This is called unquote. Available from urllib.

import urllib
urllib.unquote('%20')
+10
source

Source: https://habr.com/ru/post/1783058/


All Articles