import random # 定义一个验证码的库 code = 'abcdefdhigkmlnopqrstuvwxyzABCDEFDHIGKMLNOPQRSTUVWXYZ0123456789' checkcode = '' count = 0 # 6位数验证码 while count < 6: i = random.choice(code) checkcode += i count += 1 else: pass # python生成随机字母验证码 print(checkcode)