简体   繁体   English

如何将德语文本写入 CSV 文件?

[英]How do you write German text into a CSV file?

I'm trying to write text that was scraped from a German website into a CSV file.我正在尝试将从德国网站抓取的文本写入 CSV 文件。 I tried using UTF-8 encoding as such:我尝试使用 UTF-8 编码:

with open('/Users/filepath/result.csv', 'a', encoding='utf8') as f: f.write(text) with open('/Users/filepath/result.csv', 'a', encoding='utf8') as f: f.write(text)

But this is what appeared in the CSV file instead of with an ü:但这是出现在 CSV 文件中而不是带有 ü 的内容:

Projekt für Alleinerziehende mit mehreren (behinderten) Kindern

Try using ISO-8859-15 encoding.尝试使用 ISO-8859-15 编码。 Also make sure that when you open the file in an editor, it's encoding is set to same encoding.还要确保在编辑器中打开文件时,它的编码设置为相同的编码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM