17
我想編碼非ASCII字符,所以我可以把它們放在一個URL中,並在urlopen
中使用它們。問題是,我要像JavaScript編碼(即例如編碼ó
爲%C3%B3
):Python編碼與urllib.quote字符
encodeURIComponent(ó)
'%C3%B3'
在蟒蛇回報
但urllib.quote
ó
爲%F3
:
urllib.quote(ó)
'%F3'
我想知道如何實現像Python的encodeURIComponent
這樣的編碼,以及如果我可以編碼非中文字符的非ISO 8859-1
字符。謝謝!
相關:http://stackoverflow.com/questions/6338469/how-to-url-safe-encode-a-string -with-python-and-urllib-quote-is-wrong – geoffspear