針對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

就成功了。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM