Django报错:OSError: raw write() returned invalid length 4 (should have been between 0 and 2)

在使用Django时Django报错:Django报错:OSError: raw write() returned invalid length 4 (should have been between 0 and 2),之前是没有问题的,于是百度原因和解决办法,最终有大神分析可能与win10系统的新版本有关系,是字符编码的问题。

 

解决方案:

1.在dos终端使用 pip install win_unicode_console安装win_unicode_console;

2.在wiew.py插入下边两行代码:

 

1 import win_unicode_console
2 win_unicode_console.enable()

 

参考博客:在python中使用print()时,raw write()返回无效的长度:OSError: raw write() returned invalid length 254 (should have been between 0 and 127)

 

posted @ 2018-08-24 11:18  三教布衣  阅读(891)  评论(0编辑  收藏  举报