方法一,通过choice方式生成验证码 此方法生成每次调用crate_code()会生成三个随机数,然后再三个随机数中选择一个,资源调用相对多些 import random def v_code(code_length): res = [] if isinstance(code_length,int): for i in range(code_length): ret = create_code() res.append(ret) return res else: print("请以数字形式输入