Python编码字符串问题:字符串“Île-de-France”正以“√éle-de-France”写入CSV文件

问题描述

我正在尝试将字符串“Île-de-France”写入CSV文件,但是正在写入文件的是“√éle-de-France”。我公开尝试了 encoding =“ utf-8” ,但没有成功。我想念什么?谢谢!

with open('/tmp/directwrite.csv','w',newline='') as csvfile:
    fieldnames = ['location']
    writer = csv.DictWriter(csvfile,fieldnames=fieldnames)

    writer.writeheader()
    writer.writerow({'location': 'Île-de-France'})

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)