错误代码提示:

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

												

Python之Dijango的“坑” hostname, aliases, ipaddrs = gethostbyaddr(name) UnicodeDecodeError: 'utf-8' cod的更多相关文章

  1. python中的这些坑,早看早避免。

    python中的这些坑,早看早避免. 说一说python中遇到的坑,躲坑看这一篇就够了 传递参数时候不要使用列表 def foo(num,age=[]): age.append(num) print( ...

  2. CROC 2016 - Qualification C. Hostname Aliases map

    C. Hostname Aliases 题目连接: http://www.codeforces.com/contest/644/problem/C Description There are some ...

  3. 学Python要避免哪些坑,如何巩固好基础

    学Python要避免哪些坑?零基础怎么入门Python?Python入门简单.语法简洁.功能强大,非常适合零基础入门IT行业的人学习.随着人工智能时代的来临,企业纷纷选择使用Python进行开发,Py ...

  4. 决策树python建模中的坑 :ValueError: Expected 2D array, got 1D array instead:

    决策树python建模中的坑 代码 #coding=utf-8 from sklearn.feature_extraction import DictVectorizerimport csvfrom ...

  5. python 3以上版本使用pickle.load读取文件报UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 6

    python 3以上版本使用pickle.load读取文件报UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 6 ...

  6. Python的16个“坑”

    1. 不要使用可变对象作为函数默认值 代码如下: In [1]: def append_to_list(value, def_list=[]): ...: def_list.append(value) ...

  7. 用Java执行Python:Jython踩坑笔记

    常见的java调用python脚本方式 1.通过Jython.jar提供的类库实现 2.通过Runtime.getRuntime()开启进程来执行脚本文件 1.Jython Jpython使用时,版本 ...

  8. Python默认参数的坑

    默认参数的坑 定义一个函数,传入一个list,添加一个end再返回 def add_end(L=[]): L.append('END') return L 正常调用时,结果似乎不错 print add ...

  9. Python 中的那些坑总结——持续更新

    1.三元表达式之坑 很显然,Python把第一行的(10 + 4)看成了三元表达式的前部分,这个坑是看了<Python cookbook>(P5)中学到的,书中的代码: 2.Python生 ...

随机推荐

  1. PHP採集利器:依据開始字符串和结束字符串截取须要的採集内容数据

    PHP採集利器:依据開始字符串和结束字符串截取须要的採集内容数据 function strCutByStr(&$str, $findStart, $findEnd = false, $enco ...

  2. angular.foEach

    1.针对对象循环(key,value) 官方示例: var values = {name: 'misko', gender: 'male'}; var log = []; angular.forEac ...

  3. linux远程

    apt-get install rdesktop $rdesktop -u administrator -p ****** -a 16 192.168.1.1 //都直接登陆了,

  4. 在js里双引号里又加单引号的解决方案常用WdatePicker

    EndTime: '<input name="EndTime" type="text" class="editable center decim ...

  5. MVC3中给Html.TextAreaFor设置默认值(初始值)

    <div class="editor-field"> @Html.TextAreaFor(model => model.Comments) @Html.Valid ...

  6. linux too many open files报错

    修改方法:vi /etc/security/limits.conf  增加一行,如下: *       -       nofile          65535 修改vi /etc/ssh/sshd ...

  7. HeidiSQL数据库mysql/sql-server连接工具

    HeidiSQL,是一款可以显示表在存储中占得空间,体积小的mysql.sql-server连接工具! 下载地址: https://www.heidisql.com/download.php 中文版: ...

  8. PHP一些优先级的问题

    直接看代码 <?php echo '1'.print(2)+3,"\n"; 不错,就是这么简单,但是很少有人能正确回答 我们执行一下 [root@localhost test ...

  9. HDUOJ---------2255奔小康赚大钱

    奔小康赚大钱 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

  10. 2.Java基础:方法定义和调用

    一.方法的定义 1.类的方法代表的是实力的某种行为(或功能) 方法的定义:方法类型 . 方法签名 . 方法体 2.定义类的方法 访问修饰符 类型 方法名(参数列表){ ///方法体 } 3.把方法当作 ...