這是本身在學習pyton時寫的一個隨機驗證碼,有不對的地方歡迎指出dom
代碼學習
import random def verification(): lis = '' for i in range(4): Suiji = random.randint(1,3) if Suiji == 1: ra = random.randint(97,122) yzm = chr(ra) lis += yzm elif Suiji == 2: ra = random.randint(65, 90) yzm = chr(ra) lis += yzm else: ra = random.randint(0,9) yzm = ra lis += str(yzm) return lis Yanzhengma = verification() print(Yanzhengma)