Universally Unique Lexicographically Sortable Identifier (ULID) in Python 3
译文: Python 3中的通用唯一词典排序标识符(ULID)
ULID 由 时间戳+随机字符串
组成
01AN4Z07BY 79KA1307SR9X4MV3 |----------| |----------------| Timestamp Randomness 10chars 16chars 48bits 80bits
文档
安装
pip install ulid-py
示例
import ulid # 获取 ulid uid = ulid.new() print(uid) # 01GFHQYV8FH56G7FKP9JM612P2 print(type(uid)) # <class 'ulid.ulid.ULID'> # 获取字符串 print(uid.str) # 01GFHR0JM5CVN7KQVCZ1NVA2TK print(type(uid.str)) # <class 'str'>
参考