import datetimeimport randomimport uuid for i in range(0, 1): nowTime = datetime.datetime.now().strftime("%Y%m%d%H%M%S") randomNum = random.randint(0, 100) uniqueNum = str(nowTime) + str(randomNum) print(uniqueNum) print(uuid.uuid1()) c = [1, 2, 5]print(max(c))# 方法一Num_begin = ‘0001‘Num_Lost = [‘0008‘, ‘0005‘, ‘0007‘]if len(Num_Lost) == 0: Num_begin = int(Num_begin) + 1 if len(str(Num_begin)) < 5: s = str(Num_begin).zfill(5) print(s) else: print(Num_begin)else: print(min(Num_Lost))for i in range(1, 5): print(i)# 方法二num = []for i in range(1, 999999): num.append(random.randint(1, 999999))num.sort(reverse=False)a = 0d1 = datetime.datetime.now()n = []for i in range(1, len(num)): if num[i] - num[i - 1] != 1: for j in range(num[i - 1] + 1, num[i]): n.append(j)d2 = datetime.datetime.now()print(‘缺号:%s‘ % str(n))print(‘缺号数:%s‘ % len(n))print(‘执行时间:%s‘ % (d2-d1))
原文地址:https://www.cnblogs.com/yanhuaqiang/p/9222685.html
时间: 2024-11-04 00:17:33