#-*- coding:utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
import csv
saveDict={"用户1":"密码1","用户2":"密码2"}
fileName="filename.csv"
##保存文件
with open(fileName,"wb") as csv_file:
writer=csv.writer(csv_file)
for key,value in saveDict.items():
writer.writerow([key,value])
##读取文件
readDict={}
with open(fileName,"rb") as csv_file:
reader=csv.reader(csv_file)
readDict=dict(reader)
python将元组读写csv
最新推荐文章于 2024-09-28 17:00:00 发布