属性错误:';非类型';对象没有属性';Mrc';在python中使用jupyter笔记本
有人能告诉我哪里出了问题吗?这是我的代码和我得到的错误。 p、 s我已正确给出somefile.mrc路径属性错误:';非类型';对象没有属性';Mrc';在python中使用jupyter笔记本,python,Python,有人能告诉我哪里出了问题吗?这是我的代码和我得到的错误。 p、 s我已正确给出somefile.mrc路径 import numpy import Mrc a = Mrc.bindFile('home/smitha/deep-image-prior/data/Falcon_2015_05_14-20_42_18.mrc') # a is a NumPy array with the image data memory mapped from # somefile.mrc. You can us
import numpy
import Mrc
a = Mrc.bindFile('home/smitha/deep-image-prior/data/Falcon_2015_05_14-20_42_18.mrc')
# a is a NumPy array with the image data memory mapped from
# somefile.mrc. You can use it directly with any function
# that will take a NumPy array.
hist = numpy.histogram(a, bins=200)
# a.Mrc is an instances of the Mrc class. One thing
# you can do with that class is print out key information from the header.
a.Mrc.info()
wavelength0_nm = a.Mrc.hdr.wave[0]
AttributeError回溯(最近的调用)
最后)在()
3 a=Mrc.bindFile(“/home/smitha/deep image prior/data/Falcon_2015_05_14-20_42_18.Mrc”)
4历史=numpy.柱状图(a,箱子=200)
---->5 a.Mrc.info()
6波长0_nm=a.Mrc.hdr.波[0]
七,
AttributeError:“非类型”对象没有属性“Mrc”
AttributeError:“非类型”对象没有属性“Mrc”
表示您试图访问对象的“Mrc”
成员,即使该对象是非类型的
,因此该对象没有此类成员
您正试图在a.Mrc.info()
中执行此操作,这意味着a
是None
(NoneType
的唯一实例)。原因是
a = Mrc.bindFile('/home/smitha/deep-image-prior/data/Falcon_2015_05_14-20_42_18.mrc')
或
已将
None
分配给a
。检查每行后面的键入(a)
,查看问题所在,并调试功能这与类似(至少在中有注释)。你是如何制作mrc文件的?是的。谢谢大家!@布鲁诺·德舒利尔感谢你的杰出表现!但是,比如说,a=1
正在将int
赋值给a
,而a=None
也是如此,这难道不好吗?python函数不能在调用范围内重新绑定名称(除非函数是在调用范围中定义的闭包-这里显然不是这种情况-或者它对调用堆栈做了一些非常有害的事情,这里当然也不是这种情况),因此语句将重新绑定a
接近于零。@CIsForCookies python类是对象,所以说“a是非类型的
”意味着,字面上,a
绑定到NoneType
类对象,而不是None
对象。当你这么说时(在a=1
之后)“a
是一个int
”,这意味着a
是int
的一个实例,这与说a是int
不同;-)
hist = numpy.histogram(a, bins=200)