Python structure always stuck at 0 no matter what value you assign to it?

最后都变了- 提交于 2019-12-06 04:16:28

You could omit the 3rd field as a workaround.

>>> import ctypes
>>> class Blah(ctypes.Structure):
...   _fields_ = [("a", ctypes.c_uint64), ('b', ctypes.c_uint16), ('c', ctypes.c_uint8), ('d', ctypes.c_uint8)]
... 
>>> x = Blah(0xDEAD,0xBEEF,0x44,0x12)
>>> hex(x.a)
'0xdead'
>>> hex(x.b)
'0xbeef'

I guess the rest is a bug.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!