我习惯以这种特殊的方式写出CSV
,但我
我不知道如何包含标题,因为大多数示例都不是这种格式。
ff = open('data.csv','w')
# Included here would be a typical for loop creating the below variables, i, list_name[i], list_date[i]
ff.write( "%7d, %s, %s\n" % (i, list_name[i], list_date[i]))
答案 0 :(得分:0)
你可能想要使用csv
包,这是一个例子:
import csv
myData = [["first_name", "second_name", "Grade"],
['Alex', 'Brian', 'A'],
['Tom', 'Smith', 'B']]
myFile = open('file.csv', 'w')
with myFile:
writer = csv.writer(myFile)
writer.writerows(myData)
print("done")