欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

python模块-csv模块

程序员文章站 2022-07-10 20:22:56
...

读取数据

import csv
# print(dir(csv))
with open('Z16.csv','r',newline='',encoding='UTF-8-sig') as f1:
    reader = csv.reader(f1)
    for row in reader:
       print(row)

追加数据

 

import csv
with open('test.csv','a',newline='',encoding='utf-8') as f:
    writer = csv.writer(f)
    writer.writerow(['4', '猫砂', '25', '1022', '886'])
    writer.writerow(['5', '猫罐头', '18', '2234', '3121'])

 

 

相关标签: python模块