我在蟒蛇新鮮,使用python2.7,並得到了在代碼中的一些問題,自爆:「模塊」對象有沒有屬性「interpld」
import numpy as np
from scipy import interpolate
import pylab as py
x=np.r_[0:10:11j]
y=np.sin(x)
xnew=np.r_[0:10:100j]
#f=interpolate.interpld(x,y)
py.figure(1)
py.clf()
py.plot(x,y,'ro')
for kind in ['nearest','zero','slinear','quadtatic','cublic']:
f=interpolate.interpld(x,y,kind=kind)
ynew=f(xnew)
py.plot(xnew,ynew,label=kind)
py.legend(loc='lower right')
,但它造成了:
Traceback (most recent call last):
File "C:\Users\LCL\.xy\startups\python_web\my_first_try_on_python_web\python_Interpolation\example1.py", line 22, in <module>
f=interpolate.interpld(x,y,kind=kind)
AttributeError: 'module' object has no attribute 'interpld'
什麼'print scipy.interpolate .__ file__'說? – 2013-04-23 16:04:41
它說:C:\ Python27 \ lib \ site-packages \ scipy \ interpolate \ __ init __。pyc – ray 2013-04-23 16:12:39
至少你沒有混淆模塊。但正如下面的答案指出的那樣,你拼錯了一些東西。 – 2013-04-23 16:15:49