【发布时间】:2011-11-29 21:17:34
【问题描述】:
我在 Python 中的编码有问题。我尝试了不同的方法,但似乎找不到将输出编码为 UTF-8 的最佳方法。
这就是我想要做的:
result = unicode(google.searchGoogle(param), "utf-8").encode("utf-8")
searchGoogle 返回param 的第一个 Google 结果。
这是我得到的错误:
exceptions.TypeError: decoding Unicode is not supported
有谁知道如何让 Python 以 UTF-8 对我的输出进行编码以避免此错误?
【问题讨论】:
标签: python encoding utf-8 character-encoding