[英]Python - AttributeError: 'function' object has no attribute 'rank'
[英]AttributeError in Python function: object has no attribute
在此处输入图片描述祝大家今天好!
有人可以帮帮我吗?
我的 python 代码有什么问题?
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
@classmethod
def zero(cls):
return cls(0, 0)
def draw(self):
print(f"Point ({self.x}, {self.y}")
point = Point.zero
point.draw()
输出:
AttributeError: 'function' object has no attribute 'draw'
您没有调用 class 方法。 point
只是对它的另一个引用。
point = Point.zero()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.