1. 程式人生 > >實現隨機驗證碼

實現隨機驗證碼

cnblogs 驗證 pri str 隨機驗證碼 size rand 實現 tro

          實現隨機驗證碼

 1 #生成隨機驗證碼
 2 import random
 3 temp = ""
 4 for i in range(6):
 5     num = random.randrange(0,4)
 6     if num == 1 or num == 3:
 7         rad2 = random.randrange(0,9)
 8         temp = temp + str(rad2)
 9     else:
10         rad1 = random.randrange(65,91)
11         c1 = chr(rad1)
12 temp = temp + c1 13 print(temp)

實現隨機驗證碼