美文网首页
Pandas读取csv文件出现,AttributeError:'

Pandas读取csv文件出现,AttributeError:'

作者: 旅行小张 | 来源:发表于2020-06-24 15:20 被阅读0次

原因

python3读取csv文件的默认编码为unicode,unicode并不是编码格式,而是字符集,它包含了世界上目前所有的符号,所以unicode没有decode属性

encode,decode,分别是编码和解码,在Python中,unicode类型是编码的基础类型

解决办法

在read_csv的后面加上.astype(str)

data = pd.read_csv('route/filename.csv').astype(str)

相关文章

网友评论

      本文标题:Pandas读取csv文件出现,AttributeError:'

      本文链接:https://www.haomeiwen.com/subject/pkbrfktx.html