'''
析構函數:__del__() 釋放對象是自動調用
'''
class Person(object):
def run(self):
print("run")
def eat(self, food):
print("eat " + food)
def __init__(self, name, age, height, weight):
self.name = name
self.age = age
self.height = height
self.weight = weight
def __del__(self):
print("這里是析構函數")
per = Person("hanmeimei", 20, 170, 55)
#釋放對象
del per
#對象釋放以后就不能再訪問了
#print(per.age)
#在函數里定義的對象,會在函數結束時自動釋放,這樣可以用來減少內存空間的浪費
def func():
per2 = Person("aa", 1, 1, 1)
func()
while 1:
pass