from pyecharts.charts import Line
import json
f = open("成绩单.txt", "r", encoding="UTF-8")
data_line = f.read()
data_json = json.loads(data_line)
# print(data_json)
print(data_json[0]['科目'])
x_list = []
for x_data in data_json[0]['科目']:
x_list.append(x_data)
y_list = []
for y_data in data_json[0]['sorce']:
y_list.append(y_data)
line = Line()
line.add_xaxis("科目",x_list)
line.add_yaxis("成绩",y_list)
line.render("成绩统计图.html")
[
{
"科目": "数学",
"sorce": "100"
},
{
"科目": "语文",
"sorce": "99"
},
{
"科目": "英语",
"sorce": "98"
}
]
为啥一直提示x轴那里需要两个,但是提供了三个