with open("regulation_news_02.json", "w") as file:
file.write(json.dumps(data, indent=2, ensure_ascii=False))
报错:
Traceback (most recent call last):
File "D:/code_avivi/pycharm_project/regulation_label/scripts/get_all_theme_words.py", line 214, in <module>
file.write(json.dumps(data, indent=2, ensure_ascii=False))
UnicodeEncodeError: 'gbk' codec can't encode character '\xe3' in position 18257: illegal multibyte sequenc
改为:
with open("regulation_news_02.json", "w", encoding='utf-8') as file:
file.write(json.dumps(data, indent=2, ensure_ascii=False))