1. 程式人生 > >用python寫個隨機驗證碼

用python寫個隨機驗證碼

range emp pytho [] and random code port rand

隨機驗證碼
import random
li = []
for i in range(8):
    r = random.randrange(0,5)
    print(r)
    if r == 2 or r == 4:
        num = random.randrange(0,10)
        li.append(str(num))
    else:
        temp = random.randrange(65,123)
        char = chr(temp)
        li.append(char)
print(li)
result = ‘‘.join(li)
print(result)

用python寫個隨機驗證碼