錯誤代碼提示:
hostname, aliases, ipaddrs = gethostbyaddr(name) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcc in position 0: invalid continuation byte
在命令行輸入 python manage.py runserver啟動服務器的時候,突然出現下面的錯誤
Traceback (most recent call last): File "learning.py", line 106, in <module> main() File "learning.py", line 37, in main httpd = make_server('127.0.0.1', PORT, application) File "D:\Program Files\Python34\lib\wsgiref\simple_server.py", line 153, in ma ke_server server = server_class((host, port), handler_class) File "D:\Program Files\Python34\lib\socketserver.py", line 430, in __init__ self.server_bind() File "D:\Program Files\Python34\lib\wsgiref\simple_server.py", line 50, in ser ver_bind HTTPServer.server_bind(self) File "D:\Program Files\Python34\lib\http\server.py", line 135, in server_bind self.server_name = socket.getfqdn(host) File "D:\Program Files\Python34\lib\socket.py", line 463, in getfqdn hostname, aliases, ipaddrs = gethostbyaddr(name) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 0: invalid continuation byte
分析 :重點是最后一句紅色的話,從中我們可以看出,是要得要你自己電腦的主機名,但是現在的主機名是中文,所以導致編碼出現錯誤
解決方案:把你自己電腦的主機名改成英文的,不要寫中文,然后重啟電腦就可以了
注:你可以在python中的socket.py 中來看一下出錯的地方

