python下 numpy 读取csv文件时报错
UnicodeDecodeError: 'gbk' codec can't decode byte 0xbf in position 2: illegal multibyte sequence
解决办法:网上搜了很多,UTF-8 或者gbk,最后都不解决问题
后来发现在excel存储为csv格式时有两个选择,如下图
当我选择CSV UTF-8(逗号分隔)时,无论如何都报出上述错误。当我选择CSV(逗号分隔)时,读取顺利通过
path = 'deltalogr.csv'
with open(path, encoding='utf-8') as f:
arrayWN1 = np.loadtxt(path, dtype=str, delimiter=',', skiprows=1)
供大家参考