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

        

            

    
    
    
  • 相关阅读:
    进入黑马day4Serlet与Tomcat
    进入黑马day3HTTP协议与tomcat协议
    进入黑马day1XML简单学习
    进入黑马day2解析xml三种方法(2)sax解析器解析
    进入黑马day3xml三种解析方法比较
    进入黑马day2解析xml三种方法(1)jaxp解析
    进入黑马day2解析xml三种方法(3)dom4j解析器
    进入黑马day1JunitTest测试
    进入黑马day1关于云计算
    系统分析入门
  • 原文地址:https://www.cnblogs.com/huchong/p/7693708.html
Copyright © 2011-2022 走看看