错误代码提示:
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 FilesPython34libwsgirefsimple_server.py", line 153, in ma ke_server server = server_class((host, port), handler_class) File "D:Program FilesPython34libsocketserver.py", line 430, in __init__ self.server_bind() File "D:Program FilesPython34libwsgirefsimple_server.py", line 50, in ser ver_bind HTTPServer.server_bind(self) File "D:Program FilesPython34libhttpserver.py", line 135, in server_bind self.server_name = socket.getfqdn(host) File "D:Program FilesPython34libsocket.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 中来看一下出错的地方