user2783263
user2783263

Reputation:

How to convert ctypes.c_uint32 to int in python?

I am getting some value inside a struct, whose member is of type ctypes.c_uint32, when I try to print this value, it rather prints the characteristics of that variable like type, offset, size. I need to use that value in python program so how to convert it to int.?

Upvotes: 8

Views: 10630

Answers (1)

vaultah
vaultah

Reputation: 46523

Those objects have the value attribute:

In [14]: ct = ctypes.c_uint32(42)

In [15]: type(ct)
Out[15]: ctypes.c_uint

In [16]: ct.value
Out[16]: 42

In [17]: type(ct.value) is int
Out[17]: True

Upvotes: 14

Related Questions