摘要: import threadingimport timeimport requestsclass MyThreading(threading.Thread): def __init__(self, url): self.url = url # 给run方法传参,只能通过 self的属性 super() 阅读全文
posted @ 2022-04-23 22:24 狒狒桑 阅读(39) 评论(0) 推荐(0) 编辑
摘要: import threadingimport timefrom time import sleepdef func1(): for i in range(4): sleep(1) print(' func1 ', threading.current_thread())def func2(): for 阅读全文
posted @ 2022-04-23 22:04 狒狒桑 阅读(16) 评论(0) 推荐(0) 编辑
摘要: (1)使用type直接创建类 Test = type('Test01', (object,), {'name': 'haha', 'age': 18})t1 = Test()print(type(t1))print(Test.__dict__) (2)继承type,用继承类创建类 class MyT 阅读全文
posted @ 2022-04-23 18:24 狒狒桑 阅读(17) 评论(0) 推荐(0) 编辑
摘要: (1)描述器类 class Field: # 设置描述器类对象属性时调用 def __set__(self, instance, value): print(' __set__ ') self.value = value # 获取描述器对象属性时调用 def __get__(self, instan 阅读全文
posted @ 2022-04-23 11:15 狒狒桑 阅读(17) 评论(0) 推荐(0) 编辑
摘要: class MyClass(object): # 设置对象属性时调用 def __setattr__(self, key, value): print(' __setattr__ ') super().__setattr__(key, value) # 访问属性不存在,__getattribute_ 阅读全文
posted @ 2022-04-23 10:58 狒狒桑 阅读(17) 评论(0) 推荐(0) 编辑