python處理utf8編碼中文,及打印中文列表和字典
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)