当把中文用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
本文标题:遇到错误
本文链接:https://www.haomeiwen.com/subject/njqwaftx.html
网友评论