random 随机模块 验证码
1 def v_code(): 2 code_str = '' 3 for i in range(5): 4 import random 5 num = random.randint(0,9) 6 str1 = chr(random.randint(65,90)) 7 str2 = chr(random.randint(97,122)) 8 code_str +=str(random.choice([num,str1,str2])) 9 return code_str 10 print(v_code()) 11 输出: 12 0WT2Y
本文来自博客园,作者:竹石2020,转载请注明原文链接:https://www.cnblogs.com/ch2020/p/12395226.html
浙公网安备 33010602011771号