Django2.2版本安装之后,runserver出现以下错误
File "D:\python123\anaconda\lib\site-packages\django\views\debug.py",
line 332, in get_traceback_html
t = DEBUG_ENGINE.from_string(fh.read())
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 9737:
illegal multibyte sequence
修改方法:按着上面报错的位置打开debug.py文件,然后更改编码方式,在open中添加encodeing
with Path(CURRENT_DIR, 'templates', 'technical_500.html').open(encoding='utf-8') as fh:
t = DEBUG_ENGINE.from_string(fh.read())
成功解决!
之前总以为源代码不会出错,结果发现版本升级确实会导致很多小问题~还好有方法!