zoukankan      html  css  js  c++  java
  • Python之Django的“坑” hostname, aliases, ipaddrs = gethostbyaddr(name) UnicodeDecodeError: 'utf-8' cod

    错误代码提示:

    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 中来看一下出错的地方

        

            

    
    
    
  • 相关阅读:
    windows10 ubuntu子系统 WSL文件位置
    cs231n assignment1 KNN
    欧拉计划第五题
    欧拉计划第三题
    梯度下降入门
    Linux交换Esc和Caps
    Python实现bp神经网络识别MNIST数据集
    7-2一元多项式的乘法与加法运算
    Python实现图像直方图均衡化算法
    Python实现图像边缘检测算法
  • 原文地址:https://www.cnblogs.com/huchong/p/7693708.html
Copyright © 2011-2022 走看看