1.安装新的工具
pip install matplotlib
2.编码实现
import matplotlib.pyplot as plt
import math
import pymysql
import random
# 用来正常显示中文标签
plt.rcParams['font.sans-serif'] = ['SimHei']
# 用来正常显示负号
plt.rcParams['axes.unicode_minus'] = False
# 统计不同类别职位数量的对比
connection = pymysql.connect(host='localhost', user='root', password="123456",
database='db_2020_jobinfo', port=3306, charset='utf8')
# 2.获得游标
cursor = connection.cursor()
# 3.执行SQL语句
result = cursor.execute("select avg(meanSalary), jobType from t_job_data group by jobType;")
# 4.如果是查询操作,fetchone fetchall()
resultSet