目录
json数据格式的转换
什么是json
一种轻量级的数据交换格式,可以按json指定的格式去组织和封装数据
json本质
带有特定格式的字符串(有点像列表,字典)


python
import json
data = [{"name":"张大山","age":11},{"name":"王大锤","age":15},{"name":"赵小虎","age":13}]
str = json.dumps(data,ensure_ascii=False)
str1 = json.loads(str)
print(str)
print(type(str))
print(str1)
print(type(str1))

注意
json的对象必须是str,byts或bytearray,而不是list
pyecharts快速入门
画一个最简单的折线图
python
from pyecharts.charts import Line
line = Line()
line.add_xaxis(["中国","美国","英国"])
line.add_yaxis("GDP",[30,20,10])
line.render()


使用全局配置选项优化折线图
python
from pyecharts.charts import Line
from pyecharts.options import TitleOpts,LegendOpts,ToolboxOpts,VisualMapOpts
line = Line()
line.add_xaxis(["中国","美国","英国"])
line.add_yaxis("GDP",[30,20,10])
#设置全局配置项set_global_opts来设置,关键字传参
#position
#pos_left更改左右的位置
#pos_bottom更改上下的位置
line.set_global_opts(
title_opts=TitleOpts(title="GDP展示",pos_left="center",pos_bottom="1%"),
legend_opts=LegendOpts(is_show=True),
toolbox_opts=ToolboxOpts(is_show=True),
#视觉映射
visualmap_opts=VisualMapOpts(is_show=True)
)
line.render()


总结
