经过一些地理定位工作后,我正在使用DictWriter将字典写入csv。
location = geolocator.reverse(coords)
row["address"] = location.address
writer.writerow(row)
生成这个:
File "C:bin64python3.4.3libencodingscp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character 'u200e' in
position 118: character maps to <undefined>
我的问题是如何打开文件。我想我应该把它贴在问题上。我需要在打开文件时设置编码。
with open('results.csv', mode='w', encoding='utf-8', newline='') as file:
...