gethostbyaddr()在Python 3中引发UnicodeDecodeError [英] gethostbyaddr() raises UnicodeDecodeError in Python 3
本文介绍了gethostbyaddr()在Python 3中引发UnicodeDecodeError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
manage.py runserver
引发UnicodeDecodeException。 如何解决?查看以下(修剪)追溯:
追溯(最近的最后一次呼叫):
文件C:\ Python34\lib\socketserver.py,第429行__init__
self.server_bind()
文件C:\Python34\lib\site-packages\django\core \servers\basehttp.py,第121行
,在server_bind
超级(WSGIServer,self).server_bind()
文件C:\Python34\lib\wsgiref \simple_server.py,第50行,server_bind
HTTPServer.server_bind(self)
文件C:\Python34\lib\http\server.py,第135行, server_bind
self.server_name = socket.getfqdn(host)
文件C:\Python34\lib\socket.py,第460行,getfqdn
主机名,别名,ipaddrs = gethostbyaddr(name)
UnicodeDecodeError:'utf-8'编解码器无法解码位置12中的0xcf字节无效
连续字节
每个请求,我的主机名:
C:\Users\AnatoliyVik>主机名
AnatoliyVik-ПК
解决方案
将主机名更改为不再包含西里尔字符解决问题。
感谢@拉法达的指导。
I'm trying to build a Django project with Python 3.4.1. manage.py runserver
raises a UnicodeDecodeException.
How can this be resolved? See the below (trimmed) traceback:
Traceback (most recent call last):
File "C:\Python34\lib\socketserver.py", line 429, in __init__
self.server_bind()
File "C:\Python34\lib\site-packages\django\core\servers\basehttp.py", line 121
, in server_bind
super(WSGIServer, self).server_bind()
File "C:\Python34\lib\wsgiref\simple_server.py", line 50, in server_bind
HTTPServer.server_bind(self)
File "C:\Python34\lib\http\server.py", line 135, in server_bind
self.server_name = socket.getfqdn(host)
File "C:\Python34\lib\socket.py", line 460, in getfqdn
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcf in position 12: invalid
continuation byte
Per request, my hostname:
C:\Users\AnatoliyVik>hostname
AnatoliyVik-ПК
解决方案
Changing the hostname to no longer include Cyrillic symbols resolves the problem.
Thanks to @Lafada for the guidance.
这篇关于gethostbyaddr()在Python 3中引发UnicodeDecodeError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文