gethostbyaddr在Python3中引發(fā)UnicodeDecodeError
問題描述
我正在用Python 3.4.1來構(gòu)建一個(gè)Django項(xiàng)目。
manage.py runserver 引發(fā)UnicodeDecodeException。
如何解決?
查看以下(修剪)追溯:
追溯(最近的最后一次呼叫):
文件C:\ Python34\lib\socketserver.py,第429行__init__ self.server_bind()
文件C:\Python34\lib\site-packages\django\core \servers\basehttp.py,第121行,在server_bind 超級(jí)(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 主機(jī)名,別名,ipaddrs = gethostbyaddr(name)
UnicodeDecodeError:'utf-8'編解碼器無法解碼位置12中的0xcf字節(jié)無效連續(xù)字節(jié)
每個(gè)請(qǐng)求,我的主機(jī)名:
C:\Users\AnatoliyVik>主機(jī)名 AnatoliyVik-ПК
解決方案
將主機(jī)名更改為不再包含西里爾字符解決問題。
感謝@拉法達(dá)的指導(dǎo)。
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.
這篇關(guān)于gethostbyaddr()在Python 3中引發(fā)UnicodeDecodeError的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持腳本之家!
相關(guān)文章
淺談pytorch中torch.max和F.softmax函數(shù)的維度解釋
這篇文章主要介紹了淺談pytorch中torch.max和F.softmax函數(shù)的維度解釋,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-06-06
Python 聊聊socket中的listen()參數(shù)(數(shù)字)到底代表什么
本篇文章對(duì)Python 聊聊socket中的listen()參數(shù)(數(shù)字)到底代表什么,進(jìn)行了很好的講解,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2021-04-04
Pandas之排序函數(shù)sort_values()的實(shí)現(xiàn)
這篇文章主要介紹了Pandas之排序函數(shù)sort_values()的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07
Python?OpenCV實(shí)現(xiàn)簡(jiǎn)單的顏色識(shí)別功能(對(duì)紅色和藍(lán)色識(shí)別并輸出)
Python?OpenCV可以用來進(jìn)行顏色識(shí)別,可以通過讀取圖像的像素值,來判斷像素點(diǎn)的顏色,從而實(shí)現(xiàn)顏色識(shí)別,這篇文章主要給大家介紹了關(guān)于Python?OpenCV實(shí)現(xiàn)簡(jiǎn)單的顏色識(shí)別功能(對(duì)紅色和藍(lán)色識(shí)別并輸出)的相關(guān)資料,需要的朋友可以參考下2023-12-12
Python的socket模塊源碼中的一些實(shí)現(xiàn)要點(diǎn)分析
我們平時(shí)引入Python的socket模塊利用其中的方法可以輕松地寫出搭建socket通信的程序,今天我們就來看一下Python的socket模塊源碼中的一些實(shí)現(xiàn)要點(diǎn)分析,領(lǐng)略Python簡(jiǎn)潔代碼的一些背后功勞.2016-06-06
Python 使用 prettytable 庫(kù)打印表格美化輸出功能
這篇文章主要介紹了Python 使用 prettytable 庫(kù)打印表格美化輸出功能,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-12-12
Pytorch中如何調(diào)用forward()函數(shù)
這篇文章主要介紹了Pytorch中如何調(diào)用forward()函數(shù)問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-02-02

