python list与dict数据存储

python 存储数据报错:

UnicodeEncodeError: 'gbk' codec can't encode character '\U0001f612' in position 95: illegal multibyte sequence

 

解决:open(filename+'.json','w')  部分添加encoding='utf-8'

filename=str(yesterday)
with open(filename+'.json','w',encoding='utf-8') as outfile:
for i in data:
json.dump(i,outfile,ensure_ascii=False)
outfile.write('\n')

posted @ 2020-08-07 17:17  瞧七  阅读(619)  评论(0编辑  收藏  举报