import pymysql
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import style
import numpy as np
import matplotlib.animation as animation
style.use("fivethirtyeight")
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
db=pymysql.connect("localhost","root","root","bounce")
cursor=db.cursor()
cursor.execute("select day,visitors,bounce_rate from bounce1")
data=cursor.fetchall()
df = pd.read_sql('select day,visitors,bounce_rate from bounce1', con=db)
print(df)
df.set_index("day",inplace=True)
xar = []
yar = []
zar = []
"""for eachLine in df:
if len(eachLine)>1:
x,y,z=eachLine.split('')
xar.append(int(x))
yar.append(int(y))
xar.append(int(z))"""
ax1.clear()
ax1.plot(xar,yar,zar)
# ani = animation.FuncAnimation(fig, animate, interval=1)
plt.show()
我尝试过此代码,但行未打印