我想将dict保存到json。
我这样保存:
def save_json(json_text, output_filename):
with open(output_filename, 'w') as outfile:
outfile.write(json_text)
西里尔文形式的代码在文件中。像这样试过
def save_json(json_text, output_filename):
with open(output_filename, 'w') as outfile:
json.dump(json_text, outfile, ensure_ascii=False)
引发 AttributeError:'dict' 对象没有属性 'dump',已删除、重命名,现在最后一个选项返回
UnicodeEncodeError: 'charmap' codec can't encode character '\u20bd' in position 5: character maps to <undefined>
1 个回答