2024-07-03 07:13:45 发布
网友
我试图将foliumchoropleth编码为StringIO。我的答案是a related query。我已经检查了答案here和here。在
folium
StringIO
AttributeError: 'bytes' object has no attribute 'encode'
视图.py
经过一番反复试验,以下几点对我有用:
def get_choropleth(self, request): # make choropleth ('m') html_string = m.get_root().render() encoded_bytes = html_string.encode('utf-8') encoded_bytes = base64.b64encode(encoded_bytes) encoded_bytes = encoded_bytes.decode('utf8') # decode the b64 bytes for Unicode choropleth = encoded_bytes return {'choropleth':choropleth}
经过一番反复试验,以下几点对我有用:
解决方案
相关问题 更多 >
编程相关推荐