摘要: 用 __new__方法 #_*_ encoding: utf-8 _*_ @author: ty hery 2019/9/6 class Singleton(object): def __new__(cls): if not hasattr(cls,'_instance'): cls._instan 阅读全文
posted @ 2021-04-10 22:56 ty1539 阅读(58) 评论(0) 推荐(0) 编辑
摘要: 函数的列表作为默认参数带来的问题 #_*_ encoding: utf-8 _*_ @author: ty hery 2019/9/5 def extendList(val, list=[]): print('这个是开始之前列表: ',list) list.append(val) print(f'这 阅读全文
posted @ 2021-04-10 22:49 ty1539 阅读(99) 评论(0) 推荐(0) 编辑
摘要: #_*_ encoding: utf-8 _*_ @author: ty hery 2019/9/6 def multipliers(): return [lambda x : i * x for i in range(4)] print ([m(2) for m in multipliers()] 阅读全文
posted @ 2021-04-10 22:30 ty1539 阅读(63) 评论(0) 推荐(0) 编辑
摘要: ##生成器版斐波那契 #_*_ encoding: utf-8 _*_ @author: ty hery 2019/9/5 def fibonacci(): a,b=0,1 while True: yield b a,b = b, a+b fib=fibonacci() print(type(fib 阅读全文
posted @ 2021-04-10 22:25 ty1539 阅读(230) 评论(0) 推荐(0) 编辑
摘要: # 查出类的所有key值 cls.__table__.columns.keys() cls.__table__.columns.values() self.__class__.__name__ __get__方法详解: https://blog.csdn.net/qq_34979346/articl 阅读全文
posted @ 2021-04-10 22:12 ty1539 阅读(91) 评论(0) 推荐(0) 编辑
摘要: #_*_ encoding: utf-8 _*_ @author: ty hery 2019/9/6 def table_things(**kwargs): for name, value in kwargs.items(): print ('{0} = {1}'.format(name, valu 阅读全文
posted @ 2021-04-10 22:07 ty1539 阅读(262) 评论(0) 推荐(0) 编辑
摘要: #_*_ encoding: utf-8 _*_ @author: ty hery 2019/9/6 class Parent(object): x = 1 class Child1(Parent): pass class Child2(Parent): pass print (Parent.x, 阅读全文
posted @ 2021-04-10 22:00 ty1539 阅读(100) 评论(0) 推荐(0) 编辑