728x90
문제
기록된 json파일에 제대로 된 글자가 나오지 않는다. 한글이 \u20ac 같은 유니코드로 찍혀나옴.
해결
File을 open할 때도 encoding=’utf-8’처리를 해주고, json.dump 처리할 때도 ensure_ascii=False 처리해준다.
with open("example.json","w", encoding='utf-8') as jsonfile:
json.dump(data,jsonfile,ensure_ascii=False)
참조
https://stackoverflow.com/questions/16291358/python-saving-json-files-as-utf-8
반응형