imei码生成

代码:

def genImeiLuhn(digits14):
    digit15 = 0
    digits14 = str(digits14)
    for num in range(14):
        if num % 2 == 0:
            digit15 = digit15 + int(str(digits14)[num])
        else:
            digit15 = digit15 + (int(digits14[num]) * 2) % 10 + (int(digits14[num]) * 2) / 10
    digit15 = int(digit15) % 10
    if digit15 == 0:
        digits14 = digits14 + str(digit15)
    else:
        digits14 = digits14 + str(10 - digit15)
    return digits14


def genMassImei(stat14digits, amount, filepath):
    fo = open(filepath, "a+")
    for num in range(amount):
        imei = genImeiLuhn(stat14digits)
        stat14digits = str(int(stat14digits) + 1)
        fo.write(imei + "\n")
        print(imei)
    fo.flush()
    fo.close()


genMassImei(142430023100009, 1000, "imei2.txt")

 

posted @ 2021-11-27 11:36  阿布_alone  阅读(579)  评论(0编辑  收藏  举报
TOP