1
0
mirror of synced 2026-02-21 04:17:55 +08:00
Files
SnowFlake-IdGenerator/Python/README.md
2022-08-08 18:42:02 +08:00

27 lines
606 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ❄ idgenerator-Python
## 运行环境
Python 3.6+
## 引用 包
## 调用示例
```python
# 导入包
from source import Options,Generator
# 声明id生成器参数需要自己构建一个workerId
options = Options.IdGeneratorOptions(workerId=23)
# 参数中WorkerIdBitLength 默认值6支持的 WorkerId 最大值为2^6-1若 WorkerId 超过64可设置更大的 WorkerIdBitLength
idgen = Generator.DefaultIdGenerator()
# 保存参数
idgen.SetIdGernerator(options)
# 生成id
uid = idgen.NextId()
# 打印出来查看
print("%d, %x" % (uid,uid))
```