import csv  
 # 定义要写入CSV文件的数据  
data = [  
    ['姓名', '年龄', '城市'],  
    ['赵云', '25', '郑州'],  
    ['李红', '30', '北京'],  
    ['张军', '35', '上海']  
]  
# 打开CSV文件以写入数据  
with open('output.csv', 'w', newline='') as file:  
    writer = csv.writer(file)  
     # 写入CSV文件的每一行  
    for row in data:  
        writer.writerow(row)
