import csv
# newline='' 不会有空行 w/a 覆盖/追加读写
file =open('tttt.csv','w',encoding='utf8',newline='')
w = csv.writer(file,dialect='excel')
# 写入一行数据
w.writerow([1,2,3])
data = []
for iin range(10):
line = ['a'+str(i),i]
data.append(line)
# 写入多行数据
w.writerows(data)
file.close()