data_list = [
['id', 'name', 'age'],
[1, 'yang', 18],
[3, '大勇勇', 15],
[4, '大远', 17],
[6, '猛', 15]
]
# 加入encoding='utf-8-sig'就不会乱码了
def csv_write(path, data):
with open(path, 'w', encoding='utf-8-sig', newline='') as f:
writer = csv.writer(f, dialect='excel')
for row in data:
writer.writerow(row)
return True
csv_write('123.csv', data_list)