[-007-]-Python3+Unittest+Selenium Web UI自动化测试之@property装饰器默认值设置

看示例:

#!/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模板

 

posted @ 2023-12-12 15:43  旅行没有终点  阅读(6)  评论(0编辑  收藏  举报