我正在用 Python 和 Vincent 编写一些代码来显示一些地图数据。
文档中的示例如下所示:
import vincent
county_topo = r'us_counties.topo.json'
state_topo = r'us_states.topo.json'
geo_data = [{'name': 'counties',
'url': county_topo,
'feature': 'us_counties.geo'},
{'name': 'states',
'url': state_topo,
'feature': 'us_states.geo'}]
vis = vincent.Map(geo_data=geo_data, scale=3000, projection='albersUsa')
del vis.marks[1].properties.update
vis.marks[0].properties.update.fill.value = '#084081'
vis.marks[1].properties.enter.stroke.value = '#fff'
vis.marks[0].properties.enter.stroke.value = '#7bccc4'
vis.to_json('map.json', html_out=True, html_path='map_template.html')
运行此代码会输出一个 html 文件,但它的格式不正确。它是某种 python 字符串表示形式,b'<html>....</html>'
.
如果我删除引号和前导 b,则 html 页面在通过内置 python 服务器运行时会按预期工作。
我的输出语句有什么问题?