固定长度的uuid和生成guid

 

生成uuid

import shortuuid
def get_unique_id():
    su = shortuuid.ShortUUID(alphabet="0123456789")
    _id = int(su.random(length=19))
    return _id

 

 

19 位的guid

import shortuuid
def get_unique_id():
    su = shortuuid.ShortUUID(alphabet="0123456789")
    _id = int(su.random(length=19))
    if 1000000000000000000 < _id < 9223372036854775807:
        return _id
    return get_unique_id()

 

posted @ 2021-04-09 17:45  陨落&新生  阅读(783)  评论(0编辑  收藏  举报