摘要:
# 类的私有化 # 封装:1.私有化属性 2.定义共有set和get方法 # __属性名,就是将属性私有化,访问范围仅仅限于类中 class Person: def __init__(self, name, age): self.__name = name self.__age = age self 阅读全文
摘要:
class Animal: # 类属性 habit = '睡觉' # 魔术方法(构造方法) def __init__(self, name, age, kind): # 对象属性 # 对象中可以访问,类中不能访问 self.name = name self.age = age self.kind = 阅读全文
摘要:
#创建类对象时,自动执行的魔术方法顺序:__new__->__init__ class Person: # 魔术方法 ''' __init__:初始化魔术方法 触发时机:初始化对象时触发(不是实例化触发,但是和实例化在一个操作中) ''' def __init__(self): pass ''' _ 阅读全文
摘要:
# 1.如果装饰器是多层的,谁距离函数最近,则优先使用那个装饰器 # 2.带参数的装饰器必须有三层函数,如verify->decorate->wrapper # 添加校验功能的装饰器 import time def verify1(t): def decorate(func): def wrappe 阅读全文
摘要:
IOS移动端click事件300ms的延迟响应 fastclick可以解决在手机上点击事件的300ms延迟 zepto的touch模块,tap事件也是为了解决在click的延迟问题 触摸事件的响应顺序为 touchstart --> touchmove --> touchend --> click, 阅读全文