摘要: 多个装饰器的执行顺序 Get in decorator_aGet in decorator_b 等同于 Get in decorator_aGet in decorator_b 得出结论 装饰器函数在被装饰函数定义好后立即执行 并且是从下往上执行,最后的两句代码等同于 f=decorator_b(d 阅读全文
posted @ 2018-06-08 19:06 Operater 阅读(1695) 评论(0) 推荐(0) 编辑
摘要: 三元运算符 在python通常称为条件表达式,这些表达式基于真假的条件判断 #三元条件表达式 is_fat=True state='fat' if is_fat else 'not fat' print(state)#'fat' #元组条件表达式 fat=True fitness=('skinny','fat')[fat] print('Ali is ',fitness)#'fitne... 阅读全文
posted @ 2018-06-08 15:39 Operater 阅读(465) 评论(0) 推荐(0) 编辑
摘要: 一、__init__方法是什么 __init__方法通常用在初始化一个类实例的时候, class Person(object): """Silly Person""" def __init__(self, name, age): print('__init__ called.') self.name = name self.... 阅读全文
posted @ 2018-06-08 09:56 Operater 阅读(194) 评论(0) 推荐(0) 编辑