问题如下图所示
def df_to_html(df, out_fname, detail=0, bbox=None):
c_lng, c_lat = df.iloc[0]['Longitude'], df.iloc[0]['Latitude']
html = const_prefix % (c_lat, c_lng)
for i in range(len(df)):
lng, lat = df.iloc[i]['Longitude'], df.iloc[i]['Latitude']
marker = '[%s, %s]' % (lat, lng)
if bbox is None or (bbox is not None and bbox[0][0] <= lat <= bbox[1][0] and bbox[0][1] <= lng <= bbox[1][1]):
if detail:
html += const_circle_pop % (marker, 'red', 2, i)
else:
html += const_circle % (marker, 'red', 2)
html += const_suffix
with open(out_fname, 'w') as o_file:
o_file.write(html)
使用encoding='gb18030' 打开要写的文件就可以。'\xa9'是一个gb字符。
https://blog.csdn.net/ASN_forever/article/details/80864084
with open(out_fname, 'w',encoding='utf8') as o_file:
o_file.write(html)
估计是写入的时候编码不对,换utf8试试