看示例:
#!/usr/bin/python3 # coding:utf-8 __author__ = 'csjin' # 定义@property装饰器 class PPTListModels(object): def __init__(self): self._tab_name = "PPT模板" @property def handle(self): return self.__handle @handle.setter def handle(self,handle): self.__handle = handle @property def tab_name(self): return self.__tab_name @tab_name.setter def tab_name(self, name): self.__tab_name = name @property def case_num(self): return self.__num @case_num.setter def case_num(self, num): self.__num = num
其中,为赋默认值
def __init__(self): self._tab_name = "PPT模板"
看结果:
p = PPTListModels() print(p.tab_name) #------------------------- PPT模板
标签:Web,handle,name,Unittest,num,tab,默认值,self,def From: https://www.cnblogs.com/chushujin/p/17897070.html