python模块——random模块(简单验证码实现)

实现一个简单的验证码生成器

#!/usr/bin/env python
# -*- coding:utf-8 -*-
__author__ = "loki" # Usage: 验证码生成 import random def verification_code(digit):
verify_code = ""
for count in range(0, digit):
int_num = random.randint(0, 9)
lower_case = chr(random.randint(97, 122))
upper_case = chr(random.randint(65, 90))
compose = random.choice([int_num, lower_case, upper_case])
verify_code += str(compose)
return verify_code print(verification_code(5)) # 5位数的验证码
print(verification_code(10)) # 10位数的验证码
上一篇:Install-Package EntityFramework -version 5.0.0.0


下一篇:UE4 AI BehaviorTree 各个节点执行顺序总结