>>> with open('/proc/sys/kernel/random/uuid') as f:
... print(f.read())
...
1e21ee4f-953e-4179-9bea-ac9a0b9189e7
如果您能够安装libuuid,您将可以访问uuidgen命令行工具:
From man uuidgen
The uuidgen program creates (and
prints) a new universally unique identifier (UUID) using the libuuid(3) library. The new UUID can reasonably
be considered unique among all UUIDs created on the local system, and
among UUIDs created on other systems in the past and in the future.
我用的是
它给出了很好的预期答案e79a890c-5e3a-4c3a-bfdb-5377389b69ac
Linux内核支持生成UUID。在我的Debian系统上,可以从
/proc/sys/kernel/random/uuid
处的/proc
伪文件系统访问此功能:如果您能够安装
^{pr2}$libuuid
,您将可以访问uuidgen
命令行工具:使用这个:https://gist.github.com/mahmoudimus/56bcec09b69a2b5165aa
它是uuid模块的python2.3+兼容版本。在
示例:
使用:
^{pr2}$也可以使用:https://pypi.python.org/pypi/pyuuid/0.0.1
相关问题 更多 >
编程相关推荐