首页 > 其他分享 >csv

csv

时间:2022-08-21 21:26:48浏览次数:45  
标签:text write print csv data row

import csv

# with open('write.csv', 'r') as f: #打开
# text = csv.reader(f) #读取
# # print(text)
# for row in text: #必须这样才可以读取出数据
# print(row)

# text = csv.DictReader(f) #以字典形式读取,会以第一行数据为代表
# print(text)
# for row in text: #必须这样才可以读取出数据
# print(row)

data = [[1,2,3,4,5],[1,2,3,4,5]]
with open('write.csv', 'w') as f: #创建
# write = csv.writer(f) #录入
# for row in data:
# write.writerows(row)

write = csv.writer(f) # 录入
for row in data:
write.writerows(row)

标签:text,write,print,csv,data,row
From: https://www.cnblogs.com/lld76/p/15995125.html

相关文章