码迷,mamicode.com
首页 > 其他好文 > 详细

随机生成验证码

时间:2018-06-03 21:40:36      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:current   def   range   temp   code   lse   rand   return   int   

 1 def check_code():   #随机生成验证码
 2     import random
 3     checkcode = ‘‘
 4     for i in range(4):
 5         current = random.randrange(0, 4)
 6         if current != i:
 7             temp = chr(random.randint(65, 90))
 8         else:
 9             temp = random.randint(0, 9)
10         checkcode += str(temp)
11     return checkcode

随机生成验证码

标签:current   def   range   temp   code   lse   rand   return   int   

原文地址:https://www.cnblogs.com/jeavy/p/9129973.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!