gethostbyaddr在Python3中引發(fā)UnicodeDecodeError
問(wèn)題描述
我正在用Python 3.4.1來(lái)構(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'編解碼器無(wú)法解碼位置12中的0xcf字節(jié)無(wú)效連續(xù)字節(jié)
每個(gè)請(qǐng)求,我的主機(jī)名:
C:\Users\AnatoliyVik>主機(jī)名 AnatoliyVik-ПК
解決方案
將主機(jī)名更改為不再包含西里爾字符解決問(wèn)題。
感謝@拉法達(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)文章
python創(chuàng)建學(xué)生管理系統(tǒng)
這篇文章主要為大家詳細(xì)介紹了python創(chuàng)建學(xué)生管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-11-11Python爬蟲(chóng)實(shí)現(xiàn)全國(guó)失信被執(zhí)行人名單查詢功能示例
這篇文章主要介紹了Python爬蟲(chóng)實(shí)現(xiàn)全國(guó)失信被執(zhí)行人名單查詢功能,涉及Python爬蟲(chóng)相關(guān)網(wǎng)絡(luò)接口調(diào)用及json數(shù)據(jù)轉(zhuǎn)換等相關(guān)操作技巧,需要的朋友可以參考下2018-05-05Python3爬蟲(chóng)里關(guān)于代理的設(shè)置總結(jié)
在本篇文章里小編給大家整理的是一篇關(guān)于Python3爬蟲(chóng)里關(guān)于代理的設(shè)置總結(jié),需要的朋友們可以參考下。2020-07-07Python之自動(dòng)獲取公網(wǎng)IP的實(shí)例講解
下面小編就為大家?guī)?lái)一篇Python之自動(dòng)獲取公網(wǎng)IP的實(shí)例講解。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-10-10Python設(shè)計(jì)實(shí)現(xiàn)的計(jì)算器功能完整實(shí)例
這篇文章主要介紹了Python設(shè)計(jì)實(shí)現(xiàn)的計(jì)算器功能,結(jié)合完整實(shí)例形式分析了Python3.5實(shí)現(xiàn)計(jì)算器功能的正則、字符串及數(shù)值運(yùn)算等相關(guān)操作技巧,需要的朋友可以參考下2017-08-08python從Oracle讀取數(shù)據(jù)生成圖表
這篇文章主要介紹了python如何從Oracle讀取數(shù)據(jù)生成圖表,幫助大家更好的利用python處理數(shù)據(jù),感興趣的朋友可以了解下2020-10-10Python-OpenCV:cv2.imread(),cv2.imshow(),cv2.imwrite()的區(qū)別
本文主要介紹了OpenCV cv2.imread(),cv2.imshow(),cv2.imwrite()的區(qū)別,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-06-06python網(wǎng)絡(luò)編程:socketserver的基本使用方法實(shí)例分析
這篇文章主要介紹了python網(wǎng)絡(luò)編程:socketserver的基本使用方法,結(jié)合實(shí)例形式分析了python網(wǎng)絡(luò)編程中socketserver的基本功能、使用方法及操作注意事項(xiàng),需要的朋友可以參考下2020-04-04