加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

UnicodeDecodeError: 'gbk' codec can'

发布时间:2020-12-15 17:14:12 所属栏目:大数据 来源:网络整理
导读:背景:django == 2.2 Traceback?(most?recent?call?last):??File?"D:softwarepython3.6libwsgirefhandlers.py",?line?137,?in?run????self.result?=?application(self.environ,?self.start_response)??File?"D:softwarepython3.6libsite-packagesd

背景:django == 2.2

Traceback?(most?recent?call?last):
??File?"D:softwarepython3.6libwsgirefhandlers.py",?line?137,?in?run
????self.result?=?application(self.environ,?self.start_response)
??File?"D:softwarepython3.6libsite-packagesdjangocontribstaticfileshandlers.py",?line?65,?in?__call__
????return?self.application(environ,?start_response)
??File?"D:softwarepython3.6libsite-packagesdjangocorehandlerswsgi.py",?line?141,?in?__call__
????response?=?self.get_response(request)
??File?"D:softwarepython3.6libsite-packagesdjangocorehandlersbase.py",?line?75,?in?get_response
????response?=?self._middleware_chain(request)
??File?"D:softwarepython3.6libsite-packagesdjangocorehandlersexception.py",?line?36,?in?inner
????response?=?response_for_exception(request,?exc)
??File?"D:softwarepython3.6libsite-packagesdjangocorehandlersexception.py",?line?90,?in?response_for_exception
????response?=?handle_uncaught_exception(request,?get_resolver(get_urlconf()),?sys.exc_info())
??File?"D:softwarepython3.6libsite-packagesdjangocorehandlersexception.py",?line?125,?in?handle_uncaught_exception
????return?debug.technical_500_response(request,?*exc_info)
??File?"D:softwarepython3.6libsite-packagesdjangoviewsdebug.py",?line?94,?in?technical_500_response
????html?=?reporter.get_traceback_html()
??File?"D:softwarepython3.6libsite-packagesdjangoviewsdebug.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.6Libsite-packagesdjangoviewsdebug.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)

更改为:


(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读