1. 问题所示
通过with open('./xx.csv','r',encoding='utf-8') as csvfile:
这个代码
时候出现如下问题
TypeError: 'encoding' is an invalid keyword argument for this function
截图如下:
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/ba284f2e99a24b888d3ed09fa44fcb31.png)
2. 原理分析
在python2版本中,主要通过io内的open方法导入,增加io引入
将其此报错的代码修改为如下:
import io
with io.open('./xx.csv','r',encoding