这是自己在学习pyton时写的一个随机验证码,有不对的地方欢迎指出
代码
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)