标签:nbsp exception continue try code exce span 个数 判断
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"))
遗留问题:
怎么跳出两层循环?
给一个数字和列表,判断列表中是否存在两个元素之和等于这个数字,并好之两个数的坐标
标签:nbsp exception continue try code exce span 个数 判断
原文地址:https://www.cnblogs.com/wenm1128/p/10673821.html