C 代码类似
struct IMAGE_NT_HEADERS {
IMAGE_OPTIONAL_HEADER IMAGE_OPTIONAL_HEADER {
}
}
struct IMAGE_OPTIONAL_HEADER{....}
_(:з)∠)_。。。Python 如何做到呢?用 ctypes 没想出来怎么做
1
dbow 2017-07-12 17:24:30 +08:00 1
https://docs.python.org/2/library/ctypes.html#structures-and-unions
You can, however, build much more complicated structures. A structure can itself contain other structures by using a structure as a field type. Here is a RECT structure which contains two POINTs named upperleft and lowerright: >>> >>> class RECT(Structure): ... _fields_ = [("upperleft", POINT), ... ("lowerright", POINT)] ... >>> rc = RECT(point) >>> print rc.upperleft.x, rc.upperleft.y 0 5 >>> print rc.lowerright.x, rc.lowerright.y 0 0 >>> Nested structures can also be initialized in the constructor in several ways: >>> >>> r = RECT(POINT(1, 2), POINT(3, 4)) >>> r = RECT((1, 2), (3, 4)) |