开发者

python: convert UUID to a string which is a C unsigned char[16] initializer

(in case you're curious about motivation: this will be used in a scons build to generate a C file containing a GUID)

I found the question about generating a GUID in python. But I don't really know much about programming python. Could someone help me convert this to a string of the form

"{0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**}"

where the **'s are filled in with the GUID bytes in 2开发者_JS百科-digit hex form?

def getInitializer(someUUID):
    hexByteList = [??? for b in someUUID.bytes]
    return '{'+(', '.join(hexByteList))+'}'

I'm not sure what to use for the "???" above.


hex(ord(b))

...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜