Python:将印地文字符写入 csv
Python: writing hindi characters to csv
我正在尝试将印地语写入 Python 中的 csv,例如:
import csv
posts = open('test.csv', mode='w', errors='ignore')
post_writer_hindi = csv.writer(posts, delimiter=',', quotechar='\"', quoting=csv.QUOTE_MINIMAL)
post_writer_hindi.writerow(['नमस्ते'])
这导致实际上没有写入任何内容。应该怎么做?
open('test.csv', mode='w', errors='ignore')
将编码设置为 encoding = 'utf-8'
所以它将是 open('test.csv', mode='w', encoding = 'utf-8', errors='ignore')
我正在尝试将印地语写入 Python 中的 csv,例如:
import csv
posts = open('test.csv', mode='w', errors='ignore')
post_writer_hindi = csv.writer(posts, delimiter=',', quotechar='\"', quoting=csv.QUOTE_MINIMAL)
post_writer_hindi.writerow(['नमस्ते'])
这导致实际上没有写入任何内容。应该怎么做?
open('test.csv', mode='w', errors='ignore')
将编码设置为 encoding = 'utf-8'
所以它将是 open('test.csv', mode='w', encoding = 'utf-8', errors='ignore')