Last updated 5 years ago
Was this helpful?
在URL規範中無法直接使用特定符號,必須將其以%加上16進位數值表示
ex.
':' ---> %3A
'/' ---> %2F
若網站的GET請求中包含中文或特定符號,雖然在網址列中看起來一切正常,但把網址貼上TXT或IDE時內容則皆為百分比編碼
原始網址列 ->
貼上編輯器 -> https://tw.buy.yahoo.com/gdsale/SONY-Xperia-XA1-3G-32G-5%E5%90%8B-7100428.html
"吋"會以"%E5%90%8B"來表示
#python3 import urllib.parse print(urllib.parse.quote("吋")) #結果:%E5%90%8B print(urllib.parse.unquote("%E5%90%8B")) #結果:吋
# python2 urllib.quote(u'中文測試'.encode('utf-8'))
參考來源: