__dict__ 方法

class MainHandler:
    def __init__(self):
        self.host = "(.*)"
        self.ip =  "^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$"
        self.port = "(\d+)"
        self.phone =  "^1[3|4|5|8][0-9]\d{8}$"
        self.file = "^(\w+\.pdf)|(\w+\.mp3)|(\w+\.py)$"

    def chek(self):
        for key,val in self.__dict__.items():
            print(key,'-----',val)

obj = MainHandler()

obj.chek()

 

posted @ 2017-02-24 10:01  200ML  阅读(642)  评论(0编辑  收藏  举报