2018.7.7遇到的问题


python 读取 csv 中文 乱码

报错

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb5 in position 41: invalid start byte

解决办法1

只能读取文件中的一个字符:例如

image

执行代码后

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


posted on 2018-07-07 16:42  射手九个半  阅读(115)  评论(0编辑  收藏  举报

导航