码迷,mamicode.com
首页 > 编程语言 > 详细

Python_csv

时间:2018-01-27 17:20:07      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:csv   file   ade   文本   pytho   col   post   body   style   

1、Python 读写 csv 文件

  读取 csv 文件出现  csv.Error: iterator should return strings, not bytes

   

with open(data/name_dict.csv,r) as csvfile:
    reader = csv.reader(csvfile)
    for row in reader:
        print(row)

   错误原因:此 csv 文件并非二进制文件,是普通文本文件,不要用‘rb‘模式,改为‘r‘,或‘rt‘均可

   

Python_csv

标签:csv   file   ade   文本   pytho   col   post   body   style   

原文地址:https://www.cnblogs.com/yml6/p/8366134.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!