https://www.cnblogs.com/python-life/articles/4549996.html https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/00143178254193589df9c612d2449618ea460e7a672a366000 def fab(max): n, a, b = 0, 0, 1 while n < max: yield b a,
import random def code(n=6,alpha=True): s = '' # 创建字符串变量,存储生成的验证码 for i in range(n): # 通过for循环控制验证码位数 num = random.randint(0,9) # 生成随机数字0-9 if alpha: # 需要字母验证码,不用传参,如果不需要字母的,关键字alpha=False upper_alpha = chr(random.randint(65,90)) lower_alpha = chr(ra