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)一个指针



未完待续...

未经作者允许不得转载

posted @ 2017-08-16 17:56  wzjhoutai  阅读(1429)  评论(0编辑  收藏  举报