上传者: 38554186
|
上传时间: 2021-12-23 19:00:01
|
文件大小: 50KB
|
文件类型: -
如下所示:
import csv
with open(csv.csv,'r',encoding=utf-8) as f:
reader = csv.reader(f)
fieldnames = next(reader)#获取数据的第一列,作为后续要转为字典的键名 生成器,next方法获取
# print(fieldnames)
csv_reader = csv.DictReader(f,fieldnames=fieldnames) #self._fieldnames = fieldnames # list of keys for the dict 以list的形式存放键名