【for】生成6位随机验证码:验证码包含数字和大写字母
import random import string
def generate_code(): code = '' for i in range(6): if random.randint(0, 1): code += random.choice(string.digits) else: code += random.choice(string.ascii_uppercase) return code
print(generate_code())
原文地址: https://www.cveoy.top/t/topic/cHFM 著作权归作者所有。请勿转载和采集!