摘要:
import urllib.request import gevent from gevent import monkey monkey.patch_all() def downloader(img_name, img_url): req = urllib.request.urlopen(img_url) img_content = req.read() with open(img_name, " 阅读全文
摘要:
import gevent import time # 如果需要默认的 time.sleep(0.5) 需要打补丁 from gevent import monkey monkey.patch_all() def f1(n): for i in range(n): print(gevent.getcurrent(), i) # gevent.sleep... 阅读全文
摘要:
def create_num(all_num): print("------1------") a, b = 0, 1 current_num = 0 while current_num < all_num: print("------2------") # 如果一个函数中有yield语句,那么这个就不在是函数,而是一个生成器的模板... 阅读全文
摘要:
import time from collections import Iterable from collections import Iterator class Classmate(object): def __init__(self): self.names = list() self.current_num = 0 def add(... 阅读全文