import csv
students = [['张三', 18], ['李四', 2]]
with open('student.csv', 'w', newline='', encoding='utf-8') as f:
writer = csv.writer(f)
writer.writerow(['姓名', '年龄'])
writer.writerows(students)
# 读取文件
with open('student.csv', 'r', encoding='utf-8') as f:
reader = csv.reader(f)
for row in reader:
print(row)