我已经尝试了几种方法。据我所知,简单的使用'w'
可能是一个解决方案:
with open('test.csv', 'w') as csv_file:
writer = csv.DictWriter(csv_file, fieldnames=['header1', 'header2'], lineterminator='\n')
# write something
在Python中编写一个可在Windows中同时适用于Python 2.7+和Python 3.3+的.CSV文件
我已经尝试了几种方法。据我所知,简单的使用'w'
可能是一个解决方案:
with open('test.csv', 'w') as csv_file:
writer = csv.DictWriter(csv_file, fieldnames=['header1', 'header2'], lineterminator='\n')
# write something