Django:UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 9737: . . .

本文转自 针对django2.2报错:UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xa6 in position 9737: ill…

1、报错:

File "D:\Python\Python37-32\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

2、解决:

打开django/views下的debug.py文件,转到line331行:

with Path(CURRENT_DIR, 'templates', 'technical_500.html').open() as fh

将其改成:

with Path(CURRENT_DIR, 'templates', 'technical_500.html').open(encoding="utf-8") as fh

就成功了。

发布了119 篇原创文章 · 获赞 86 · 访问量 5857

猜你喜欢

转载自blog.csdn.net/BBJG_001/article/details/104395541