大学生流浪十余年,河北二本院校,卡努法典
import random
# 生成随机验证码
# 数字验证码
check_code = ''
for i in range(4):
current = random.randint(1, 9)
check_code += str(current)
print(check_code)
# 随机字母+数字验证码
check_code = ''
for i in range(4):
current = random.randrange(0, 4)
if current == i:
tmp = chr(random.randint(65, 90))
else:
tmp = random.randint(0, 9)
check_code += str(tmp)
print(check_code)
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
新手学习Python2和Python3中print不同的用法
Python基于os.environ从windows获取环境变量
网友评论