這個編碼的名字是什麼?unicode的未知編碼
SMB:// NAS /音樂/ _lib/V/VOIVOD/VOIVOD-RRR%C3%B6%C3%B6%C3%B6aaarrr/01%20-%20voivod%20-%20rrr%C3% B6%C3%B6%C3%B6aaarrr%20-%20korg%C3%BCll_the_exterminator.mp3
我想使用Python將此類字符串轉換爲unicode。我會怎麼做?
這個編碼的名字是什麼?unicode的未知編碼
SMB:// NAS /音樂/ _lib/V/VOIVOD/VOIVOD-RRR%C3%B6%C3%B6%C3%B6aaarrr/01%20-%20voivod%20-%20rrr%C3% B6%C3%B6%C3%B6aaarrr%20-%20korg%C3%BCll_the_exterminator.mp3
我想使用Python將此類字符串轉換爲unicode。我會怎麼做?
這是URL編碼的UTF-8。 URL解碼,然後解碼爲UTF-8。
嘗試urllib.unquote()。
import urllib
>>> m="smb://nas/music/_lib/v/voivod/voivod-rrr%C3%B6%C3%B6%C3%B6aaarrr/01%20-%20voivod%20-%20rrr%C3%B6%C3%B6%C3%B6aaarrr%20-%20korg%C3%BCll_the_exterminator.mp3"
>>> m1= urllib.unquote(m)
>>> print(repr(m))
'smb://nas/music/_lib/v/voivod/voivod-rrr\xc3\xb6\xc3\xb6\xc3\xb6aaarrr/01 - voivod - rrr\xc3\xb6\xc3\xb6\xc3\xb6aaarrr - korg\xc3\xbcll_the_exterminator.mp3'
>>> m2= m1.decode('utf8')
>>> print(m2)
smb://nas/music/_lib/v/voivod/voivod-rrröööaaarrr/01 - voivod - rrröööaaarrr - korgüll_the_exterminator.mp3
完美!...謝謝! – jldupont 2010-11-09 01:37:35