def code_get(self): source = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] #数字验证码 # source = [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H','I','J', 'K','L', 'M', 'N','O','P','Q','R', # 'S', 'T', 'U', 'V', 'W', 'Z','X', 'Y'] #字母验证码 return ''.join(random.sample(source, number)) # number是生成验证码的位数