python 基础常用库

json

import json


data = [{"name":"xxx","age":15},{"name":"xxwsx","age":15},{"name":"xxdx","age":15},{"name":"xxewx","age":15}]
jsonStr = json.dumps(data,ensure_ascii=False)
print(type(jsonStr))
print(jsonStr)

data = {"name":"xxx","age":15,"address":"xxxxx33","price":1000}
jsonStr = json.dumps(data,ensure_ascii=False)
print(type(jsonStr))
print(jsonStr)


jsonStr = '[{"name": "xxx", "age": 15}, {"name": "xxwsx", "age": 15}, {"name": "xxdx", "age": 15}, {"name": "xxewx", "age": 15}]'
data = json.loads(jsonStr)
print(type(data))
print(data)

jsonStr = '{"name": "xxx", "age": 15, "address": "xxxxx33", "price": 1000}'
data = json.loads(jsonStr)
print(type(data))
print(data)

pyecharts 简单实用

from pyecharts.charts import Line
from pyecharts.options import TitleOpts
from pyecharts.options import LegendOpts
from pyecharts.options import ToolboxOpts
from pyecharts.options import VisualMapOpts

line = Line()
line.add_xaxis(["中国","美国","日本"])
line.add_yaxis("GDP",[30,20,10])
line.set_global_opts(title_opts=TitleOpts(title="xxxxx",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()
map = Map()

data = [("北京",12),("上海",12),("深圳",12),("广州",12)]
map.add("test map",data,"china")
map.set_global_opts(title_opts=TitleOpts(title="xxxxx",pos_left="center",pos_bottom="1%"),
                     legend_opts=LegendOpts(is_show=True),
                     toolbox_opts=ToolboxOpts(is_show=True),
                     visualmap_opts=VisualMapOpts(is_show=True,is_piecewise=True,
                                                  pieces=[{"min":1,"max":9,"label":"1-9","color":"#CCFFFF"},
                                                          {"min":10,"max":99,"label":"10-99","color":"#CCFFEE"},
                                                          {"min":100,"max":199,"label":"100-1999","color":"#CCFFBB"},
                                                          ]
                                                  ))
map.render()

你可能感兴趣的:(python,java,服务器)