diff options
Diffstat (limited to 'Lib/csv.py')
-rw-r--r-- | Lib/csv.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/csv.py b/Lib/csv.py index 59ec372ec0a..5ae5a730468 100644 --- a/Lib/csv.py +++ b/Lib/csv.py @@ -127,6 +127,10 @@ class DictWriter: self.extrasaction = extrasaction self.writer = writer(f, dialect, *args, **kwds) + def writeheader(self): + header = dict(zip(self.fieldnames, self.fieldnames)) + self.writerow(header) + def _dict_to_list(self, rowdict): if self.extrasaction == "raise": wrong_fields = [k for k in rowdict if k not in self.fieldnames] |