2018.7.7遇到的问题
python 读取 csv 中文 乱码
报错
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb5 in position 41: invalid start byte
解决办法1
只能读取文件中的一个字符:例如
执行代码后
import codecs
with codecs.open('E:\\python\\automatedtest\\SystemManagement\\excel\\kjkm_acco.csv', 'rb', 'gb2312') as csvfile:
for line in csvfile:
print line[0]
结果:
C:\Python27\python.exe E:/python/自动化测试/系统管理/1.十个模板页的增删改查/12.py
1
Process finished with exit code 0

浙公网安备 33010602011771号