Created
August 7, 2015 03:26
-
-
Save cocodrips/282b29f91e966d39a2fd to your computer and use it in GitHub Desktop.
csv.DictWriterの挙動
This file contains hidden or 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 | |
rows = [ | |
{ | |
"a": "a", | |
"b": "b" | |
}, { | |
"a": 1, | |
"b": 2 | |
}, { | |
"a": 3, | |
"b": 4 | |
} | |
] | |
writer = csv.DictWriter(open('dicttocsv.csv', 'w'), rows[0].keys()) | |
for row in rows: | |
writer.writerow(row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result