0
將數據寫入csv文件編碼問題如何解決它
import csv
a = [u'eaTfxfwz', u'Edward', u'O\u2019Connell', u'[email protected]', u'Santa Clara', u'CA', 'UNITED STATES', u'150 Saratoga Avenue #306', u'', u'Santa Clara, CA', u'95051', u'', u'408-835-2209', u'None', u'', '', u'2012-010', u'pjOjJfwT', u'Undefined', u'Import', u' ', ' San Jose HQ, CA ', '', '', u'Undefined', '', u'None', '', '', u'Undefined', u'Not Considered', '', u'']
f3 = open('test.csv', 'at')
writer = csv.writer(f3,delimiter = ',', lineterminator='\n',quoting=csv.QUOTE_ALL)
writer.writerow(a)
的錯誤,我得到這個錯誤
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 1: ordinal not in range(128)
如何修復
可能的重複http://stackoverflow.com/questions/18766955/how-to-write-utf-8-in-a-csv-file。 – citaret