我正在开发定制的Linux。当我使用requests进行一些HTTP发布时,出现了一个导入异常,在idna中。再说一句话,我的系统是小端Linux。
>>> from uts46data import uts46data
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
LookupError: unknown encoding: utf-32-be
>>>
我检查了以下编码。
>>> import sys
>>> sys.getdefaultencoding()
'utf-8'
>>> sys.getfilesystemencoding()
'ANSI_X3.4-1968'
我猜这是一个编码问题,那我该怎么办?
更多信息如下。
/ # python -c "import sys;print(sys.version)"
2.7.8 (default, Jul 7 2020, 07:25:41)
[GCC 7.3.1 20180425]
/ # python -c "import codecs;print codecs.lookup('utf-32-be')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
LookupError: unknown encoding: utf-32-be
/ #
答案 0 :(得分:0)
回答自己。
Python将在encodings目录中定位其编码文件。您可以从Python源包的Lib / encodings目录下复制相应的编码文件。