目的
我正在尝试将foliumchoropleth编码为StringIO. 我基于我对相关查询的回答。我已经在这里和这里检查了答案。
错误
AttributeError: 'bytes' object has no attribute 'encode'
代码
视图.py
def get_choropleth(self, request):
# make choropleth ('m')
html_string = m.get_root().render()
f = StringIO(html_string)
choropleth = base64.b64decode(f.read())
choropleth = choropleth.encode('utf8') # causing error
return {'choropleth':choropleth}
海绵宝宝撒
相关分类