zl程序教程

您现在的位置是:首页 >  后端

当前栏目

python生成订单号或生成任意序列

Python序列 生成 任意 订单号
2023-09-11 14:15:15 时间

python生成订单号或生成任意序列

示例代码:

import time


#  生成订单号
def get_order_code():
    #  年月日时分秒+time.time()的后7位
    order_no = str(time.strftime('%Y%m%d%H%M%S', time.localtime(time.time())) + str(time.time()).replace('.', '')[-7:])
    return order_no


print(get_order_code())

运行结果: