python析构函数
#
!/user/bin/python
#
-*-coding:UTF-8-*-
from
__future__
import print_function # 兼容python2.x和python3.x的print语句class Fruit(object):
def__init__(self,color):# 初始化属性__color
self.__color = color
print(self.__color)
def__del__(self):# 析构函数
self.__color = ""print("free...")
def grow(self):
print("grow...")
if__name__=="__main__":
color = "red"
fruit = Fruit(color)
fruit.grow()
参考:https://baike.baidu.com/item/%E6%9E%90%E6%9E%84%E5%87%BD%E6%95%B0/9483718?fr=aladdin
原文:https://www.cnblogs.com/herd/p/13769272.html
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!