Java like function getLeastSignificantBits() & getMostSignificantBits in Python?

前端 未结 2 1222
小蘑菇
小蘑菇 2021-01-15 12:59

Can someone please help me out in forming an easy function to extract the leastSignificant & mostSignificant bits in Python?

Ex code in Java:

UUI         


        
2条回答
  •  隐瞒了意图╮
    2021-01-15 13:23

    Old post but still... Just thought I'd add this:

    import struct
    import uuid
    
    u = uuid.UUID('c88524da-d88f-11e9-9185-f85971a9ba7d')
    msb, lsb = struct.unpack(">qq", u.bytes)
    

    This give the values:
    (-3997748571866721815, -7960683703264757123) ... and if I input those into the java.util.UUID constructor, it gives me back the uuid "c88524da-d88f-11e9-9185-f85971a9ba7d"

提交回复
热议问题