Skip to content

Instantly share code, notes, and snippets.

@seozed
Last active September 7, 2021 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seozed/027d968e7700211b649f57a944c2778d to your computer and use it in GitHub Desktop.
Save seozed/027d968e7700211b649f57a944c2778d to your computer and use it in GitHub Desktop.
将字典列表写入到csv文件中
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