简体   繁体   中英

Cannot unicode chinese character using python2

I try to initialize Chinese words in python3, but it throws 'charmap' codec can't encode characters in position 98-100: character maps to <undefined>

I already tried to place u before the words:

import re

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

The console shows that 'charmap' codec can't encode characters in position 98-100: character maps to <undefined>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM