How to convert ctypes' c_long to Python's int?

Viewed 29035

int(c_long(1)) doesn't work.

3 Answers

Use the 'value' attribute of c_long object.


  c_long(1).value

or


  i = c_long(1)
  print i.value

>>> type(ctypes.c_long(1).value)
<type 'int'>
Related