import random
while True:
def makeCode(length=4):
str= “0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM”
i = 1
code=""
while i <= length:
r= random.randint(0,len(str)-1)
code += str[r]
i+=1
return code
c = input(“请输入验证码的长度:”)
if c == “”:
code = makeCode(4)
else:
cc = int©
code= makeCode(cc)
print(“生成的验证码是:%s” % code)
在这里插入代码片