问题
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