Last active
September 7, 2021 07:01
-
-
Save seozed/027d968e7700211b649f57a944c2778d to your computer and use it in GitHub Desktop.
将字典列表写入到csv文件中
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
# 字典列表 | |
result_list = [] | |
with open('weibo_data.csv', 'w', newline='', encoding='gbk') as csv_file: | |
# header field | |
fieldnames = result_list[0].keys() | |
writer = csv.DictWriter(csv_file, fieldnames=fieldnames) | |
writer.writeheader() | |
writer.writerows(result_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment