import matplotlib.pyplot as plt
import numpy as np
plt.title("year-olders Function",fontsize=12)
plt.xlabel("year")
plt.ylabel("olders")
year=[2000,2001,2002,2003,2004,2005,2006,2007,2008,2009]
older=[88274022,90615170,93770690,96920250,98790880,100682120,103843920,107024490,110225660,113432500]
plt.scatter(year,older)
w=0.5
for i in range(10):
x=year[i] #x=1
y=older[i] #y=0.89
data=w*x #y_pre=0.5*1=0.5
e=y-data #e=0.39
alpha=0.05
w=w+alpha*e*x #w=0.5+0.05*0.39*1=0.5195
data=w*year
plt.plot(year,data)
plt.show()
这段代码是哪里出错了呢,”data=w*year“这一行一直在报TypeError: can't multiply sequence by non-int of type 'float'错误,请赐教。