Мой код ниже:
with open('C:\\Users\\...\\Documents\\RP_test_8.txt', 'w') as f:
cf = csv.DictWriter(f, column_headers, extrasaction='ignore')
cf.writeheader()
cf.writerows(r.data for r in records)
дает мне исключение кодирования Unicode:
UnicodeEncodeError Traceback (most recent call last)
<ipython-input-141-410d45c40cce> in <module>()
2 cf = csv.DictWriter(f, column_headers, extrasaction='ignore')
3 cf.writeheader()
----> 4 cf.writerows(r.data for r in records)
C:\Users\...\AppData\Local\Continuum\anaconda2\lib\csv.pyc in writerows(self, rowdicts)
156 for rowdict in rowdicts:
157 rows.append(self._dict_to_list(rowdict))
--> 158 return self.writer.writerows(rows)
159
160 # Guard Sniffer's type checking against builds that exclude complex()
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 30: ordinal not in range(128)
Как лучше всего справиться с этим?