我想将一些日文字符写入csv,但我无法正确显示它。 csv最终会出现像æ|æ这样的字符,我不确定我做错了什么。
import requests
import csv
r = requests.get('http://jisho.org/api/v1/search/words?keyword=%23common')
data = r.json()
with open('common_words.csv', 'a', newline='', encoding='utf-8') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=['word','reading'])
for entry in data["data"]:
word = entry["japanese"][0]["word"]
reading = entry["japanese"][0]["reading"]
writer.writerow({'word':word,'reading':reading,})
答案 0 :(得分:0)
代码是正确的。用excel读取csv文件是个问题。使用文本编辑器打开文件可正确显示字符。