无法使用python2 Unicode中文字符

时间:2019-06-18 07:43:10

标签: python

我尝试在python3中初始化中文单词,但它抛出'charmap' codec can't encode characters in position 98-100: character maps to <undefined>

我已经尝试将u放在以下单词之前:

import re

CONTRACT_PARTY_KEYWORD = [u'lesser', u'lesse', u'出租方', u'承租方']
ADDRESS_KEYWORD = [u'城市', u'广州市房屋租赁合同']
DATE_KEYWORD = [u'因为', u'日期', u'月', u'自', u'日']

控制台显示'charmap' codec can't encode characters in position 98-100: character maps to <undefined>

1 个答案:

答案 0 :(得分:0)

在文件顶部添加# -*- coding: utf-8 -*-