Heim  >  Fragen und Antworten  >  Hauptteil

python - numpy读取csv文件报“UnicodeEncodeError”

numpy读取csv文件报“UnicodeEncodeError”,使用的python3
1.csv内容:
APPL,28-01-2011,,344.17,344.4,333.53,3336.1,21144800
代码如下:

import numpy as np
c,v = np.loadtxt('1.csv',usecols=(6,7),unpack=True)

报错:
“UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-1: ordinal not in range(256)”

c,v = np.loadtxt(open('1.csv', encoding='latin-1'),usecols=(6,7),unpack=True)

又报错:
IndexError: list index out of range
google了良久,没有找到解决方法,这个例子是“Python数据分析基础教程:NumPy学习指南(第2版)”第三章中的一个例子。

黄舟黄舟2741 Tage vor1087

Antworte allen(1)Ich werde antworten

  • PHPz

    PHPz2017-04-18 10:18:42

    latin-1是什么编码

    Antwort
    0
  • StornierenAntwort