【发布时间】:2015-11-06 17:16:59
【问题描述】:
有'cp1251'的默认编码--如何在Python3中默认改为UTF-8?因为函数 sys.setdefaultencoding() 不起作用
【问题讨论】:
-
你认为你为什么需要这样做?
-
因为我使用 urllib.request 解析西里尔文 (\xd0\x9e \xd0\x9a\xd0) 时给了我错误的字符
-
所以正确编码/解码..另见this
-
meta.stackexchange.com/questions/66377/what-is-the-xy-problem - 尝试使用自动将请求解码为 Unicode 字符串的 Requests 库
标签: python encoding utf-8 cp1251