谁能帮我解决这个例外?
File "/root/anaconda2/lib/python2.7/site-packages/numba/dispatcher.py", line 305, in _compile_for_args
argtypes.append(self.typeof_pyval(a))
File "/root/anaconda2/lib/python2.7/site-packages/numba/dispatcher.py", line 429, in typeof_pyval
File "/root/anaconda2/lib/python2.7/site-packages/numba/typing/typeof.py", line 28, in typeof
ty = typeof_impl(val, c)
File "/root/anaconda2/lib/python2.7/site-packages/singledispatch.py", line 210, in wrapper
return dispatch(args[0].__class__)(*args, **kw)
AttributeError: class FeatureEncoding has no attribute '__class__'
答案 0 :(得分:0)
并非每个实例都具有__class__
属性。只是一般性建议:在大多数情况下,最好使用type
代替__class__
。
例如,旧式课程没有课程:
>>> class A:
... pass
...
>>> A.__class__
AttributeError: class A has no attribute '__class__'
>>> int.__class__ # just for comparison the class of the int class
<type 'type'>
但type
有效:
>>> type(A)
<type 'classobj'>
注意:旧式类的实例具有__class__
属性
>>> a = A()
>>> a.__class__
<class __main__.A at 0x0000000002E61168>