遇到错误
2018-10-12 本文已影响0人
MrHA_ec98
当把中文用json.dumps写入文件时
with open('file.txt','a',encoding='utf-8') as f:#打开文件需要用utf-8格式打开
f.write(json.dumps('strings',ensure_ascii=False))#ensure_ascii需要设置成false
当把中文用json.dumps写入文件时
with open('file.txt','a',encoding='utf-8') as f:#打开文件需要用utf-8格式打开
f.write(json.dumps('strings',ensure_ascii=False))#ensure_ascii需要设置成false