快速激活码生成V2,激活码生成V2,# coding=utf


# coding=utf-8# config 为配置词典# y 是长度 最终生产出来的验证码是 长度 = Y - title的长度# x 是循环次数 生成数量# title 是激活码最前固定字符串 留空代表不使用import stringimport randomimport MySQLdbdb = MySQLdb.connect("localhost", "root", "123456", "Python")cursor = db.cursor()cursor.execute("DROP TABLE IF EXISTS JHM")  # 如果有JHM这个数据库就删除cursor.execute(    """CREATE TABLE JHM(id int(11) primary key AUTO_INCREMENT, jhm CHAR(20) NOT NULL , status CHAR(1) NOT NULL)""")config = {'y': 10, 'x': 20, 'title': "Dota"}def jhm(num):    b = ''.join(random.sample(string.ascii_letters + string.digits, num))    return bdef sql(w):    try:        cursor.execute(w)    except:        db.rollback()for z in range(config['x']):    w = "INSERT INTO JHM(jhm,status)VALUES ('%s','%s')" % (        config['title'] + jhm(config['y'] - len(config['title'])), '0')    sql(w)db.commit()db.close()

评论关闭