脚本——生成验证码的函数
#-*- coding:UTF-8 -*- # generate verification import random def generate_verification_code(lenth=6): code_list=[] for i in range(10): code_list.append(str(i)) for i in range(65,91): code_list.append(chr(i)) for i in range(97,123): code_list.append(chr(i)) myslice=random.sample(code_list,lenth) verification_code=' '.join(myslice) return verification_code print generate_verification_code()