固定长度的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()

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM