UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 9737: illegal multibyte sequence

UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 9737: illegal multibyte sequence,第1张

概述UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 9737: illegal multibyte sequence

背景:django == 2.2

Traceback (most recent call last):  file "D:\software\python3.6\lib\wsgiref\handlers.py", line 137, in run    self.result = application(self.environ, self.start_response)  file "D:\software\python3.6\lib\site-packages\django\contrib\staticfiles\handlers.py", line 65, in __call__    return self.application(environ, start_response)  file "D:\software\python3.6\lib\site-packages\django\core\handlers\wsgi.py", line 141, in __call__    response = self.get_response(request)  file "D:\software\python3.6\lib\site-packages\django\core\handlers\base.py", line 75, in get_response    response = self._mIDdleware_chain(request)  file "D:\software\python3.6\lib\site-packages\django\core\handlers\exception.py", line 36, in inner    response = response_for_exception(request, exc)  file "D:\software\python3.6\lib\site-packages\django\core\handlers\exception.py", line 90, in response_for_exception    response = handle_uncaught_exception(request, get_resolver(get_URLconf()), sys.exc_info())  file "D:\software\python3.6\lib\site-packages\django\core\handlers\exception.py", line 125, in handle_uncaught_exception    return deBUG.technical_500_response(request, *exc_info)  file "D:\software\python3.6\lib\site-packages\django\vIEws\deBUG.py", line 94, in technical_500_response    HTML = reporter.get_traceback_HTML()  file "D:\software\python3.6\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

解决办法:

python3.6\lib\site-packages\django\vIEws\deBUG.py

原:

def get_traceback_HTML(self):    """Return HTML version of deBUG 500 http error page."""    with Path(CURRENT_DIR, 'templates', 'technical_500.HTML').open() as fh:        t = DEBUG_ENGINE.from_string(fh.read())    c = Context(self.get_traceback_data(), use_l10n=False)    return t.render(c)

更改为:


总结

以上是内存溢出为你收集整理的UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 9737: illegal multibyte sequence全部内容,希望文章能够帮你解决UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 9737: illegal multibyte sequence所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/langs/1229856.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存