这不起作用:class ifinfomsg(ctypes.Structure):
_fields_ = [
('ifi_family', ctypes.c_ubyte),
('__ifi_pad', ctypes.c_ubyte),
('ifi_type', ctypes.c_ushort),
('ifi_index', ctypes.c_int),
('ifi_flags', ctypes.c_uint),
('ifi_change', ctypes.c_uint(0xFFFFFFFF))
]
It错误:
^{pr2}$
但是我可以设置__init__()中的值:class ifinfomsg(ctypes.Structure):
_fields_ = [
('ifi_family', ctypes.c_ubyte),
('__ifi_pad', ctypes.c_ubyte),
('ifi_type', ctypes.c_ushort),
('ifi_index', ctypes.c_int),
('ifi_flags', ctypes.c_uint),
('ifi_change', ctypes.c_uint)
]
def __init__(self):
self.__ifi_pad = 0
self.ifi_change = 0xFFFFFFFF
通过__init__这是正确的方法吗?在