我找到了以下帖子How to pack a UUID into a struct in Python?,但它没有解决我的问题:
我有以下uuid:
from uuid import UUID
b = UUID("3f687986-e905-11e0-b641-f04da24096ca")
我需要打包它,我需要从中获取以下字节代码: “\ X33 \ X66 \ X36 \ X38 \ X37 \ X39 \ X38 \ X36 \ X2D \ X65 \ X39 \ X30 \ X35 \ X2D \ X31 \ X31 \ X65 \ X30 \ X2D \ X62 \ X36 \ X34 \ X31 \ X2D \ X66 \ X30 \ X34 \ 64 \ X61 \ X32 \ X34 \ X30 \ X39 \ X36 \ X63 \ X61'
顺便说一下,我得到了这个输出:
''.join(['\\' + hex(ord(i))[1:] for i in str(b)])
我找不到办法。
有可能吗?怎么样?
谢谢!