我无法访问结构元素。注意,我已经用 但Python似乎没有意识到这一点。所以我加了一个声明 为了分配一个值,Python会意识到其中有一些东西。只有当我读入 结构。。。正如我读到的一个库隆,这是很好的工作。在
class vendrRecord(Structure):
_pack_ = 1 # pack the struct
_fields_ = [
("ytdPayments" ,c_ulong),
]
VendrRecord = vendrRecord()
libc = cdll.msvcrt
libc.sscanf(b"1 2 3", b"%d", byref(VendrRecord)) # read something into the structure
dsi_lib = ctypes.cdll.LoadLibrary(find_library('DsiLibrary_dll')) # using my library just to give access to a dump routine
dsi_lib.DsmDumpBytes( byref(VendrRecord), 4 ) # this prints 0000: 01 00 00 00
print(vendrRecord.ytdPayments) # this prints <Field type=c_ulong, ofs=0, size=4>. I expected it to print 1
vendrRecord.ytdPayments = 2
print(vendrRecord.ytdPayments) # this prints 2
打印的是类变量而不是实例变量(请注意大小写):
输出:
^{pr2}$相关问题 更多 >
编程相关推荐