首页 > 其他 > 详细

random 随机模块 验证码

时间:2020-03-02 14:22:13      阅读:69      评论:0      收藏:0      [点我收藏+]
 1 def v_code():
 2     code_str = ‘‘
 3     for i in range(5):
 4         import random
 5         num = random.randint(0,9)
 6         str1 = chr(random.randint(65,90))
 7         str2 = chr(random.randint(97,122))
 8         code_str +=str(random.choice([num,str1,str2]))
 9     return code_str
10 print(v_code())
11 输出:
12 0WT2Y

 

random 随机模块 验证码

原文:https://www.cnblogs.com/ch2020/p/12395226.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!