file:///home/ashu/Music/Collections/randomPicks/ipod%20on%20sep%2009/Coldplay-Sparks.mp3
如何转换上述字符串以获取可以传递给open()
函数的普通文件路径?
答案 0 :(得分:16)
查看url2pathname
:
import urllib2
path = urllib2.url2pathname("file:///home/ashu/Music/Collections/randomPicks/ipod%20on%20sep%2009/Coldplay-Sparks.mp3")
答案 1 :(得分:10)
这称为unquote。可以从urllib获得。
import urllib
urllib.unquote('%20')