【问题标题】:How to open CSV in python using CSV library? [duplicate]如何使用 CSV 库在 python 中打开 CSV? [复制]
【发布时间】:2020-11-02 16:48:46
【问题描述】:

我在 python 中的这段代码有问题。它返回一个错误:

line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 3310: character maps to <undefined>. 

我该如何解决?

import csv

exampleFile = open('example-base.csv')
exampleReader = csv.reader(exampleFile)
exampleData = list(exampleReader)
exampleData

【问题讨论】:

    标签: python csv


    【解决方案1】:

    试试这个

    examplefile = open(file_name, encoding="utf8")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-09
      • 2019-09-07
      • 1970-01-01
      • 2014-12-03
      • 2013-08-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多