Using the lowercase function with CSV rows

会有一股神秘感。 提交于 2019-12-07 10:55:52

问题


I'm trying to print all data from a csv in lowercase, but I'm not having any luck.

Here's what I have so far:

import csv
books = csv.reader(open("books.csv","rb"))

for row in books:
    print row

This prints all the content of the csv, but when I add the .lower() function, I get errors.

What am I doing wrong?


回答1:


Try

print [r.lower() for r in row]


来源:https://stackoverflow.com/questions/8265648/using-the-lowercase-function-with-csv-rows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!