如何更改 CSV 文件中使用的分隔符?

How do I change the delimiter used in CSV file?

UnicodeDecodeError:'charmap' 编解码器无法解码位置 2219 中的字节 0x9d:字符映射到

非常感谢你的帮助

来自CSV Examples

open() is used to open a CSV file for reading, the file will by default be decoded into unicode using the system default encoding (see locale.getpreferredencoding())。要使用不同的编码解码文件,请使用 open:

的编码参数
import csv
with open('some.csv', newline='', encoding='utf-8') as f:
    reader = csv.reader(f)
    for row in reader:
        print(row)

这同样适用于以系统默认编码以外的方式编写:在打开输出文件时指定编码参数。