A list of numbers and for determining whether there are two elements of the list is equal to this number, the coordinates of the two numbers and good

import random
import os.path

def get_mobile_no(mobile_no_file_path):

    mobile_no =""
    prifix =[135,136,137,138,150,159,188]

    while 1:
        mobile_prifix =random.choice(prifix)
        mobile_postfix =str(random.randint(0,99999999)).zfill(8)
        mobile_no =str(mobile_prifix)+str(mobile_postfix)
        try:
            with open(mobile_no_file_path,"a+") as fp:
                if mobile_no in fp.read():
                    continue
                fp.write(mobile_no+"\n")
                break
        except  Exception as e:
            with open("no.txt","a+") as fp:
                if mobile_no in fp.read():
                    continue
                fp.write(mobile_no+"\n")
                break
    return mobile_no

print(get_mobile_no("d:\\no2.txt"))

 

 

Remaining problem:

How two out of circulation?

Guess you like

Origin www.cnblogs.com/wenm1128/p/10673821.html