1.基本读取方式
import csvcsv_reader=csv.reader(open('account.csv',encoding='utf-8'))for row in csv_reader: print(row)#account.csv在同一目录下
2..读取文件中的某一列以及多列
import csvwith open('account.csv',encoding='utf-8') as csvfile: reader=csv.reader(csvfile) column=[row[2] for row in reader] print(column)
3.读取文件的某一行
import csvwith open('account.csv',encoding='utf-8') as csvfile: reader=csv.reader(csvfile) for i,rows in enumerate(reader): if i==0: row=rows print(row)
4.读取文件的行数
import csva=open("account.csv","r")b=len(a.readline())print(b)