利用python实现简单随机验证码

 1 #!/usr/bin/env python
 2 # -*- coding:utf-8 -*-
 3 import random
 4 temp =''
 5 for i in range(6):
 6     num = random.randrange(0,4)
 7     if num ==3 or num == 1:
 8         rad2 = random.randrange(0,10)
 9         temp = temp + str(rad2)
10     else:
11         rad1 = random.randrange(65,91)
12         c1 = chr(rad1)
13         temp = temp + c1
14 
15 print(temp)

 

posted @ 2017-02-10 08:00  Erick-LONG  阅读(221)  评论(0编辑  收藏  举报