简体   繁体   English

如何从python生成常量唯一ID

[英]how generate a constant Unique id from python


my application need use python generate a constant Unique id for run machine. 我的应用程序需要使用python为运行的机器生成一个恒定的唯一ID。
the constant Unique id mean is : 恒定的唯一ID平均值是:
anytime in the same machine ,generate Unique id is always the SAME Unique id. 随时在同一台计算机上,生成唯一ID始终是相同的唯一ID。

(maybe like system uuid,but my application not run root,cant't get system-uuid). (也许像系统uuid,但我的应用程序无法运行root,无法获得system-uuid)。
btw,i think python uuid model not good for me: 顺便说一句,我认为python uuid模型对我不好:
uuid1():use time,gen a uuid,this is not a constant Unique id uuid1():使用时间,生成一个uuid,这不是一个常量唯一ID
uuid3():cant use some string gen a uuid,but this uuid same in any machine. uuid3():不能在uuid中使用某些字符串,但是此uuid在任何机器中都相同。



Thanks! 谢谢!

the same machine: The same cpu+motherboard+OS instalation+same disk. 同一台机器:相同的cpu +主板+ OS安装+相同的磁盘。 action : 动作:
uuid1():use time gen a uuid,this is not a constant Unique id uuid1():使用时间生成一个uuid,这不是常量唯一ID

You could try snowflake . 你可以试试雪花 If you have root, the ID can be persistent for the whole machine; 如果您具有root用户,则该ID可以在整个计算机上保持不变; otherwise, it can just save the ID in a file you have permission to create. 否则,它只能将ID保存在您有权创建的文件中。

Disclosure: I wrote it. 披露:我写的。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM