Python3 ctypes简单使用

>>> from ctypes import *
>>> c_int()
c_long(0)
>>> c_char_p(b'hello')
c_char_p(b'hello')
>>> c_ushort(-5)
c_ushort(65531)
>>> seitz = c_char_p(b'loves the python')
>>> print(seitz)
c_char_p(b'loves the python')
>>> print(seitz.value)
b'loves the python'

最后一个示例将一个指向字符串'loves the python'的ctype指针赋给变量作值seutz.随后我们通过访问seitz.value方法获取指针所指向的内容,我们称这个过程为解除引用(dereferencing)一个指针



未完待续...

未经作者同意不得转载


版权声明:本文为u013511642原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。