Python ';模块';对象没有属性';interpld';
我刚接触python,使用python2.7,对代码有一些疑问:Python ';模块';对象没有属性';interpld';,python,module,Python,Module,我刚接触python,使用python2.7,对代码有一些疑问: 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','
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'
回溯(最近一次呼叫最后一次):
文件“C:\Users\LCL\.xy\startups\python\u web\my\u first\u try\u on\u python\u web\python\u Interpolation\example1.py”,第22行,in
f=插值.interpld(x,y,种类=种类)
AttributeError:“模块”对象没有属性“interpld”
您使用了interpld
,即interpld
您需要
interp1d
,即带有数字1
,用于一维。您使用interpld
,即interpld
您需要
interp1d
,即使用数字1
,用于一维。看起来您正在使用interpold.interpold
,但函数名为interpolate.interp1d
(用数字1代替字母L).看起来您使用的是interpole.interpld
,但函数名是interpole.interp1d
(用数字1代替字母L)。它应该是“interp1d”,数字1,而不是L它应该是“interp1d”,数字1,不是L打印scipy.interpolate.\uuuuu文件\uuuuuu说什么?它说:C:\Python27\lib\site packages\scipy\interpolate\u init\ucat至少你当时没有混淆模块。但正如下面的答案所指出的,您拼错了一些东西。print scipy.interpolate.\uuuuu file\uuuu
怎么说?上面写着:C:\Python27\lib\site packages\scipy\interpolate\u init\ucat至少您当时没有混淆模块。但正如下面的答案所指出的,您拼错了一些东西。我刚刚修复了它,但这里出现了另一个问题:回溯(最近一次调用):文件“C:\Users\LCL\.xy\startups\python\u web\my\u first\u try\u on\u python\u Interpolation\example1.py”,第22行,在f=interpolate.interp1d(x,y,kind=kind)文件中“C:\Python27\lib\site packages\scipy\interpolate\interpolate.py”,第272行,在init中“其他类型的例程”。%kind)未实现错误:不支持四进制:对其他类型使用fitpack例程。同样,您可能指的是quadratic
,而不是quadratic
。。。而cublic
应该是cubic
。您可以在文档中看到允许值的列表(help(interpolate.interp1d)
)。哦,我从youtube视频中了解到,我是一个多么粗心的人,感谢您指出我刚刚修复了它,但这里出现了另一个问题:回溯(最近一次调用):File“C:\Users\LCL\.xy\startups\python\u web\my\u first\u try\u on\u python\u web\python\u Interpolation\example1.py”,第22行,在f=interpolate.interp1d(x,y,kind=kind)文件“C:\Python27\lib\site packages\scipy\interpolate\interpolate.py”的init“其他类型的例程”第272行。%kind)未实现错误:不支持四进制:对其他类型使用fitpack例程。同样,您可能指的是quadratic
,而不是quadratic
。。。而cublic
应该是cubic
。您可以在文档中看到允许值的列表(help(interpolate.interp1d)
)。哦,我从youtube视频中了解到,我是一个多么粗心的人,感谢您指出我刚刚修复了它,但这里出现了另一个问题:回溯(最近一次调用):File“C:\Users\LCL\.xy\startups\python\u web\my\u first\u try\u on\u python\u web\python\u Interpolation\example1.py”,第22行,在f=interpolate.interp1d(x,y,kind=kind)文件“C:\Python27\lib\site packages\scipy\interpolate\interpolate.py”的init“其他类型的例程”第272行。“%kind)未实现错误:不支持quadtatic:对其他类型使用fitpack例程。@ray:你是说“quartatic”而不是“quadtatic”?哦,我从youtube视频中了解到,我是一个多么粗心的人,感谢你指出我刚刚修复了它,但这里出现了另一个问题:回溯(最近一次调用):文件“C:\Users\LCL\.xy\startups\python\u web\my\u first\u try\u on\u python\u web\python\u Interpolation\example1.py”,第22行,在f=interpolate.interp1d(x,y,kind=kind)文件“C:\Python27\lib\site packages\scipy\interpolate\interpolate.py”的init“其他类型的例程”第272行。“%kind)未实现错误:不支持四边形:对其他类型使用fitpack例程。@ray:你是说“二次型”而不是“四边形”吗?哦,我从youtube视频中了解到,我是一个多么粗心的人,谢谢你指出“它”是什么意思?你能进一步解释吗?你说的“它”是什么意思?你能进一步解释一下吗?