Python中ULID通用唯一词典排序标识符如何生成?

2026-04-30 20:421阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计151个文字,预计阅读时间需要1分钟。

Python中ULID通用唯一词典排序标识符如何生成?

Python 3中的通用唯一词法排序标识符(ULID):Python 3中的通用唯一词法排序标识符(ULID)是一种结合了时间戳、随机字符的标识符,格式为01AN4Z07BY 79KA1307SR9X4MV3。

Universally Unique Lexicographically Sortable Identifier (ULID) in Python 3

译文: Python 3中的通用唯一词典排序标识符(ULID)

ULID 由 时间戳+随机字符串 组成

Python中ULID通用唯一词典排序标识符如何生成?

01AN4Z07BY 79KA1307SR9X4MV3 |----------| |----------------| Timestamp Randomness 10chars 16chars 48bits 80bits

文档

  • github.com/ahawker/ulid

安装

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'>

参考 ULID - 一种比UUID更好的方案

本文共计151个文字,预计阅读时间需要1分钟。

Python中ULID通用唯一词典排序标识符如何生成?

Python 3中的通用唯一词法排序标识符(ULID):Python 3中的通用唯一词法排序标识符(ULID)是一种结合了时间戳、随机字符的标识符,格式为01AN4Z07BY 79KA1307SR9X4MV3。

Universally Unique Lexicographically Sortable Identifier (ULID) in Python 3

译文: Python 3中的通用唯一词典排序标识符(ULID)

ULID 由 时间戳+随机字符串 组成

Python中ULID通用唯一词典排序标识符如何生成?

01AN4Z07BY 79KA1307SR9X4MV3 |----------| |----------------| Timestamp Randomness 10chars 16chars 48bits 80bits

文档

  • github.com/ahawker/ulid

安装

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'>

参考 ULID - 一种比UUID更好的方案