python
python编程中遇到的一些坑
无名指上的痛
这个作者很懒,什么都没留下…
展开
-
Python多线程
1.函数实现:对于不同任务 import threading loop = 10000 num = 0 def _add(loop): global num name = threading.current_thread().getName() for i in range(1oop): num += i def _sub(loop): name = threading.current_thread().getName() global num for i in range(1oop):原创 2022-01-21 15:49:51 · 378 阅读 · 0 评论 -
Python装饰器
1.类作为装饰器 class TimeDecorator(object): def __init__(self, f): self.f = f def __call__(self, *args): start_time = time.time() result = self.f(*args) end_time = time.time() print('Time elapsed for {}'.format(end_time - start_time)) return result原创 2021-07-13 16:30:23 · 81 阅读 · 0 评论