python--random生成隨機驗證碼

import random def code(n=6,alpha=True): s = '' # 建立字符串變量,存儲生成的驗證碼 for i in range(n): # 經過for循環控制驗證碼位數 num = random.randint(0,9) # 生成隨機數字0-9 if alpha: # 須要字母驗證碼,不用傳參,若是不須要字母的
相關文章
相關標籤/搜索