2019年1月27日

异常

摘要: #异常一 :可以预知的异常 可以用if条件避免#游戏猜年纪:AGE = 25age = input('>>>')if age.isdecimal(): if int(age) > AGE: print('答对啦!')#异常二,不可以预知的异常,用try 和 except接收try: f = open('a.txt', 'r', encoding='utf-8') p... 阅读全文

posted @ 2019-01-27 21:00 别离 阅读(166) 评论(0) 推荐(0) 编辑

自定义元类控制类的实例化行为的应用

摘要: #实现方式一class Mysql: __instance = None # __instance = s def __int__(self): self.post = 1.235 self.host = 3 @classmethod def singleton(cls): if not cls._ 阅读全文

posted @ 2019-01-27 13:47 别离 阅读(175) 评论(0) 推荐(0) 编辑

导航