import csv
# 1. 创建文件对象
filename = 'D:/AAA.csv'
f = open(filename,'w',encoding='utf-8',newline="")
# 2. 构建 csv写入对象
csv_writer = csv.writer(f)
# 3. 写入文件头
csv_writer.writerow(["姓名","年龄","性别"])
# 4. 写入csv文件内容
csv_writer.writerow(["张三",'15','男'])
csv_writer.writerow(["李四",'14','男'])
csv_writer.writerow(["
王五",'15','女'])
# 5. 关闭文件
f.close()
print(f"File {filename} was created.")