学习:流水编号
Posted yanhuaqiang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了学习:流水编号相关的知识,希望对你有一定的参考价值。
import datetime
import random
import 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 = 0
d1 = 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))
以上是关于学习:流水编号的主要内容,如果未能解决你的问题,请参考以下文章