python写入txt 和python写入csv 202208
作者:互联网
##写入csv
dic=[1,2,3,4,5]
# # file = open('21.txt', mode='w',encoding='UTF-8')
# # file.write(dic)
# # # 关闭文件,不关闭文件可能会出问题
# # file.close()
#########################################################
##写入csv import csv f=open('data.csv','w') csvwriter=csv.writer(f) dic=[1,2,3,4,5] csvwriter.writerow(dic) f.close()
#########################################################
##写入csv import csv f=open('data.csv','w') csvwriter=csv.writer(f) dic=[1,2,3,4,5] csvwriter.writerow(dic) f.close()
标签:python,写入,202208,dic,##,file,close,csv 来源: https://www.cnblogs.com/hnmy/p/16591162.html