Python的getter和setter方法

class HtmlName:
    def __init__(self):
        self.__value = ''


    def get_report(self):
        time.sleep(0.001)
        return self.__value


    def set_report(self, newvalue):
        self.__value = newvalue 

使用

report = HtmlName() #  实例化类
report.set_report(newvalue)  #  传递参数
report = report.get_report() #  获取值
原文地址:https://www.cnblogs.com/ShineLeem/p/12012905.html