python處理utf8編碼中文,需要在py文件的第一行加入:# -*- coding:utf-8 -*- 或者 #coding=utf-8
打印字符串時,使用print str.encode('utf8');
打印中文列表時,使用循環 for key in list:print key
打印中文字典時,可以使用循環,也可以使用json:
import json
print json.dumps(dict, encoding='UTF-8', ensure_ascii=False)
python處理utf8編碼中文,需要在py文件的第一行加入:# -*- coding:utf-8 -*- 或者 #coding=utf-8
打印字符串時,使用print str.encode('utf8');
打印中文列表時,使用循環 for key in list:print key
打印中文字典時,可以使用循環,也可以使用json:
import json
print json.dumps(dict, encoding='UTF-8', ensure_ascii=False)
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。