Python3 -- CSV读取文件
直接上代码:
# coding: utf-8 import csv csvfile = file('csv_test.csv', 'rb') reader = csv.reader(csvfile) for line in reader: print line csvfile.close()
import csv with open(filepath, 'r', encoding='utf8') as f: reader = csv.reader(f) for item in reader:
# item 每行的数据(列表格式[1, 2, 3, 4]) print(item)