摘要: #导入系统模式 import sys #定义获取信息的函数()文件名,所在函数名,当前行数 def get_head_info(): try: raise Exception except: f = sys.exc_info()[2].tb_frame.f_back return (f.f_code 阅读全文
posted @ 2017-11-20 20:01 19950216 阅读(508) 评论(0) 推荐(0) 编辑
摘要: import abc class user(metaclass = abc.ABCMeta): #属性 username='' #方法 #添加用户 @abc.abstractmethod def add (self,name,pwd): pass #删除用户 @abc.abstractclassme 阅读全文
posted @ 2017-11-20 18:51 19950216 阅读(297) 评论(0) 推荐(0) 编辑
摘要: #必须导入抽象类模块 import abca class Dog(metaclass = abc.ABCMeta): #制定类的元素 age =10 sex = 'man' #方法 #对象抽象方法 @abc.abstractmethod def swinmming(self): pass #静态抽象 阅读全文
posted @ 2017-11-20 12:48 19950216 阅读(276) 评论(0) 推荐(0) 编辑
摘要: 装饰器的基本实现: def kuozhan(func): def newruixin(): #扩展功能: print('如果我说如果‘) #调用基本函数 func print('没有如果‘) #增加返回值 return newruixin #基本函数 @kuozhan #ruixin = kuozh 阅读全文
posted @ 2017-11-20 11:55 19950216 阅读(87) 评论(0) 推荐(0) 编辑