如何将 ctypes 的 c_long 转换为 Python 的 int?
Posted
技术标签:
【中文标题】如何将 ctypes 的 c_long 转换为 Python 的 int?【英文标题】:How to convert ctypes' c_long to Python's int? 【发布时间】:2011-01-20 19:06:42 【问题描述】:int(c_long(1))
不起作用。
【问题讨论】:
【参考方案1】:>>> ctypes.c_long(1).value
1
【讨论】:
【参考方案2】:使用 c_long 对象的 'value' 属性。
c_long(1).value
或
i = c_long(1)
print i.value
【讨论】:
【参考方案3】:>>> type(ctypes.c_long(1).value)
<type 'int'>
【讨论】:
以上是关于如何将 ctypes 的 c_long 转换为 Python 的 int?的主要内容,如果未能解决你的问题,请参考以下文章
[转] python关于ctypes使用char指针与bytes相互转换的问题