python - Encoding csv error with Pandas - have to encode one csv file but not the other -both have same encoding
问题描述
I am using pandas to read in csv data to my python script. Both csv files have the same encoding (Windows-1252). However with one of the files I get an error when reading the csv file with pandas, unless I specify the encoding parameters in pd.read_csv().
Does anyone know why I need to specify the encoding in one csv and not the other? Both csv's contain similar data (strings and numbers).
Thank you
解决方案
这只是意味着其中一个文件的字符超出了 0x00 到 0x7F 的范围。只有编码产生影响的最高 128 个值。只需要一个带波浪号的 n 或一个智能引号。
推荐阅读
- r - 编织到pdf时如何阻止rmarkdown生成“附加包”
- c - 为什么在 Linux 上调用 open() 会自动替换为 openat()?
- java - 使用 Hazelcast 客户端部署选项部署 Cassandra 驱动程序会出现以下错误
- r-markdown - 使用图像编织 Rmarkdown 文档时的 TOC 问题
- python - 如何使用 KIvy 中的弹出小部件(按钮)从类中访问小部件/ID
- python - 使用 continue 循环,和或
- c++ - 为什么不能覆盖继承的类虚函数?
- str-replace - str_replace 和 htmlspecialchars 不起作用
- php - ArgumentCountError 函数参数太少 Laravel 无法从数据库中提取数据并显示
- python - 从字符串中删除(可能嵌套的)花括号内的所有文本