运行环境:

Windows 10 专业版 64位

Python27

Django1.11

Mysql5.7

IIS 10 或 Apache24

项目通过控制台或pycharm运行访问正常,但是部署到IIS或Apache访问时报以下错误:

IIS或Apache部署Django项目,访问时报:UnicodeEncodeError


解决方法:

在python安装目录的Lib\site-packages文件夹下新建文件:sitecustomize.py,然后复制以下内容到文件中,保存并重启项目即可。

# -*- coding: utf-8 -*-
import sys

reload(sys)
sys.setdefaultencoding('utf8')


相关文章:

  • 2022-12-23
  • 2021-05-08
  • 2022-12-23
  • 2022-01-22
  • 2021-04-25
  • 2022-12-23
  • 2021-10-14
  • 2022-12-23
猜你喜欢
  • 2021-08-15
  • 2022-12-23
  • 2021-09-30
  • 2021-10-20
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案