csv保存数据

import csv
import time,random
csv_lists=[[1,2],[3,4],[5,6]]
for csv_list in csv_lists:
time.sleep(random.randint(3,5))
with open("D:\pythonProject\技术提升\工具\读写文件\csv.csv", "a", encoding="UTF-8", newline="") as csvfile:
writer = csv.writer(csvfile)
writer.writerow(csv_list)
print('************************************')
print(f"索引:{csv_lists.index(csv_list)}")
print(f'{csv_list}')
print('************************************')

print('存入完成')
posted @ 2021-09-29 15:01  布都御魂  阅读(82)  评论(0编辑  收藏  举报