python四位随机验证码源码展示!原来验证码都是这样生成的!

import random
test1 = (1,2,3,4,5,6,7,8,9,0,)
test2 = ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',)
num1 = random.sample(test1,2)
nump1 = random.sample(test2,2)
test_out = random.sample(num1 + nump1,4)
test_print = str(test_out[0]) + str(test_out[1]) + str(test_out[2]) + str(test_out[3])
print(test_print)
if __name__ == '__import_':
 main()
此文比较适合初学者,在对python有更深层次的了解后,可以知道还有更简便的写法,
python语言精华就是精练,大家有好的方法可以互相交流一下

python四位随机验证码源码展示!原来验证码都是这样生成的!

进群:516107834 即可获取数十套PDF哦!

猜你喜欢

转载自blog.csdn.net/qq_42156420/article/details/83474208
今日推荐