当我使用Python2.7并试图通过以下方式声明Python源代码编码时:
#!/usr/bin/python
# -*- coding: utf-8 -*-
当我通过以下方式检查文件编码时:
check_encoding = sys.getdefaultencoding()
logger.warning("check_encoding ")
我得到:
ascii
当我使用python 3时,我可以通过声明源代码编码:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
当我通过以下方式检查文件编码时:
检查编码=sys.getDefaultEncoding()
logger.warning(“检查编码”)
我得到:
utf-8
我不知道Python2.7版本有什么问题,也不知道是什么原因造成的。