我试图找到" uuid -d"的等价选项。在python中使用linux命令,最后使用下面的Extract the time from a UUID v1 in python:
request_id = 78577992-6170-11e8-a1e4-f3a982af936e
request_uuid = uuid.UUID(request_id)
print (datetime.fromtimestamp((request_uuid.time - 0x01b21dd213814000L)*100/1e9))
打印时间为" 2018-05-27 15:40:31.803023",这与" uuid -d"中显示的实际时间不同命令:
uuid -d 78577992-6170-11e8-a1e4-f3a982af936e |grep "content: time:"
content: time: 2018-05-27 05:40:31.803022.6 UTC
是否有正确的选项可以使用uuid或任何内置模块从python中的UUID中提取时间信息?
答案 0 :(得分:0)
您提供的request_id
与您使用uuid -d
测试的uuid不同。如果您更正了这些差异,则会对应(使用Extract the time from a UUID v1 in python的答案进行检查。)