lines=[];
表头数据
lines.append(list(retlist[0].keys()))
明细数据
for city in city_list:
{
lines.append(list(city.values()))
}
f.open('api.csv','w',encoding='utf-8',newline='')
writer = csv.writer(f)
for line in lines:
writer.writerow(line)
f.close()