新西兰服务器

gethostbyaddr在Python3中引发UnicodeDecodeError怎么解决


gethostbyaddr在Python3中引发UnicodeDecodeError怎么解决

发布时间:2022-05-20 17:48:40 来源:高防服务器网 阅读:63 作者:iii 栏目:开发技术

这篇文章主要介绍“gethostbyaddr在Python3中引发UnicodeDecodeError怎么解决”,在日常操作中,相信很多人在gethostbyaddr在Python3中引发UnicodeDecodeError怎么解决问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”gethostbyaddr在Python3中引发UnicodeDecodeError怎么解决”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

问题描述

我正在用Python 3.4.1来构建一个Django项目。

 manage.py runserver 引发UnicodeDecodeException。

如何解决?

查看以下(修剪)追溯:

追溯(最近的最后一次呼叫):

文件C: Python34libsocketserver.py,第429行__init__  self.server_bind()

文件C:Python34libsite-packagesdjangocore serversbasehttp.py,第121行,在server_bind 超级(WSGIServer,self).server_bind()

文件C:Python34libwsgiref simple_server.py,第50行,server_bind  HTTPServer.server_bind(self)

文件C:Python34libhttpserver.py,第135行, server_bind  self.server_name = socket.getfqdn(host)

文件C:Python34libsocket.py,第460行,getfqdn 主机名,别名,ipaddrs = gethostbyaddr(name)

UnicodeDecodeError:'utf-8'编解码器无法解码位置12中的0xcf字节无效连续字节 

每个请求,我的主机名:

 C:UsersAnatoliyVik>主机名 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:Python34libsocketserver.py", line 429, in __init__      self.server_bind()    File "C:Python34libsite-packagesdjangocoreserversbasehttp.py", line 121  , in server_bind      super(WSGIServer, self).server_bind()    File "C:Python34libwsgirefsimple_server.py", line 50, in server_bind      HTTPServer.server_bind(self)    File "C:Python34libhttpserver.py", line 135, in server_bind      self.server_name = socket.getfqdn(host)    File "C:Python34libsocket.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:UsersAnatoliyVik>hostname  AnatoliyVik-ПК

Changing the hostname to no longer include Cyrillic symbols resolves the problem.

Thanks to @Lafada for the guidance.

到此,关于“gethostbyaddr在Python3中引发UnicodeDecodeError怎么解决”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注高防服务器网网站,小编会继续努力为大家带来更多实用的文章!

[微信提示:高防服务器能助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。

[图文来源于网络,不代表本站立场,如有侵权,请联系高防服务器网删除]
[