【发布时间】:2013-08-10 14:46:48
【问题描述】:
我试图让 python 给我百分比编码的字符串。我正在与之交互的 API(我认为它使用百分比编码的 UTF-8)为 î 提供 %c3%ae。但是,python 的 urllib.quote 给出了 %3F。
import urllib
mystring = "î"
print urllib.quote(mystring)
print urllib.quote_plus(mystring)
print urllib.quote(mystring.encode('utf-8'))
任何帮助表示赞赏。
【问题讨论】:
-
我已经执行了你的代码,它打印出
%C3%AE。%3F,顺便说一句,是?char 编码的。
标签: python utf-8 url-encoding