python----特性001

特性001:python 中特性的一个例子:

#!/usr/local/python3.5/bin/python3

class Person(object):
    def __init__(self,name):
        self.name=name
    def get_name(self):
        print('this is get name')
        return self.name
    def set_name(self,name):
        print('this is set name')
        self.name=name
    def del_name(self):
        print('this is del name')
        del self.name
    Name = property(get_name,set_name,del_name,'name property ...')

if __name__=="__main__":
    jlx=Person('Jianglexing')
    print(jlx.Name)

 

posted on 2016-08-07 14:23  蒋乐兴的技术随笔  阅读(190)  评论(0编辑  收藏  举报

导航