Python CTYPE结构::如何设置值(A.B.dataType) - 混淆哪个点是错误

时间:2013-12-28 13:55:16

标签: python python-2.7 ctypes

下面提到的是我的结构

class CameraDevTMsgType(ctypes.Structure):
    _fields_ = [("Cmd", ctypes.c_char), ("width", ctypes.c_int), ("height", ctypes.c_int), ("brightness", ctypes.c_int),
                ("contrast", ctypes.c_int), ("saturation", ctypes.c_int), ("gain", ctypes.c_int),
                ("quality", ctypes.c_int), ("file", ctypes.c_char * 20), ("device", ctypes.c_char * 20),
                ("nextcmd", ctypes.c_char * 20), ("delay", ctypes.c_int)]


class CameraMsgType(ctypes.Structure):
    _fields_ = [("Status", ctypes.c_int), 
                ("Cmd", ctypes.c_int),
                ("settings", CameraDevTMsgType), 
                ("dateFormat", ctypes.c_int),
                ("DBdate", ctypes.c_char * 11),
                ("DBtime", ctypes.c_char * 9),
                ("isDeposit", ctypes.c_char * 2)]

使用 CameraMsgType 实例确认如何在 CameraDevTMsgType 中设置字段文件的值 像:

s=CameraMsgType()
s.settings.file = "XXXX"

当我尝试这个时它如何实现它显示异常

0 个答案:

没有答案