以下错误:“ UnicodeEncodeError:'ascii'编解码器无法在位置2编码字符u'\ xc4':顺序号不在范围(128)中”
mydict = {
'SNo': ['1','2','3'],
'Name': ['Dinesh', 'Rajesh', 'Mahesh'],
'Grade': ['α', 'β', 'γ']
}
with open('info.csv', 'wb') as f:
header = mydict.keys()
writer = csv.DictWriter(f, fieldnames=header)
writer.writeheader()
for pivoted in zip(*mydict.values()):
writer.writerow(dict(zip(header, pivoted)))
Python 2.7版
预期产量
Error: UnicodeEncodeError: 'charmap' codec can't encode character '\u03b1' in position 9: character maps to <undefined>