我想知道是否可以从自己的函数中删除一个对象。这就是我的想法:
class ball:
def __init__(self, a):
self.a = a
def update(self, t):
if t >= self.a:
del self # Need help here
myBall = ball(120)
for i in range(0, 1000):
myBall.update(i)
答案 0 :(得分:0)
del self
只是删除引用,而不是实际对象。
self
是对象的引用。