You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 606 B

2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
1234567891011121314151617181920212223242526
  1. # ❄ idgenerator-Python
  2. ## 运行环境
  3. Python 3.6+
  4. ## 引用 包
  5. ## 调用示例
  6. ```python
  7. # 导入包
  8. from source import Options,Generator
  9. # 声明id生成器参数,需要自己构建一个workerId
  10. options = Options.IdGeneratorOptions(workerId=23)
  11. # 参数中,WorkerIdBitLength 默认值6,支持的 WorkerId 最大值为2^6-1,若 WorkerId 超过64,可设置更大的 WorkerIdBitLength
  12. idgen = Generator.DefaultIdGenerator()
  13. # 保存参数
  14. idgen.SetIdGernerator(options)
  15. # 生成id
  16. uid = idgen.NextId()
  17. # 打印出来查看
  18. print("%d, %x" % (uid,uid))
  19. ```