#!/usr/bin/python
class Test:
name = ""
## like toString in Java
def __str__(self):
return "class Test..."
##constructor
def __init__(self,name='xxx'):
self.name = name
##destructor
def __del__(self):
del self.name
print "destructor"
print self.name
test1 = Test()
print test1.name
test2 = Test("hello")
print test2.name
最后
以上就是帅气钢铁侠最近收集整理的关于python构造与析构的全部内容,更多相关python构造与析构内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复