用法:
_fields_
定义结构字段的序列。这些项目必须是 2 元组或 3 元组。第一项是字段的名称,第二项指定字段的类型;它可以是任何 ctypes 数据类型。
对于像
c_int
这样的整数类型字段,可以给出第三个可选项目。它必须是一个小的正整数,定义字段的位宽。字段名称在一个结构或联合中必须是唯一的。此项不勾选,重复名称时只能访问一个字段。
可以定义
_fields_
类变量after
定义 Structure 子类的类语句,这允许创建直接或间接引用自身的数据类型:class List(Structure): pass List._fields_ = [("pnext", POINTER(List)), ... ]
然而,
_fields_
类变量必须在第一次使用类型之前定义(创建实例,在其上调用sizeof()
,等等)。稍后分配给_fields_
类变量将引发AttributeError可以定义结构类型的sub-subclasses,它们继承基类的字段加上sub-subclass 中定义的
_fields_
,如果有的话。
相关用法
- Python ctypes.Structure._anonymous_用法及代码示例
- Python cudf.core.column.string.StringMethods.is_vowel用法及代码示例
- Python cudf.Series.ceil用法及代码示例
- Python cudf.core.column.string.StringMethods.endswith用法及代码示例
- Python cuxfilter.charts.datashader.heatmap用法及代码示例
- Python cudf.Series.update用法及代码示例
- Python calendar firstweekday()用法及代码示例
- Python cusignal.windows.windows.hann用法及代码示例
- Python cudf.DataFrame.mod用法及代码示例
- Python cudf.DataFrame.isin用法及代码示例
- Python cudf.core.column.string.StringMethods.title用法及代码示例
- Python cuml.metrics.pairwise_distances.pairwise_distances用法及代码示例
- Python collections.somenamedtuple._replace用法及代码示例
- Python cuxfilter.charts.panel_widgets.int_slider用法及代码示例
- Python cudf.DataFrame.rmul用法及代码示例
- Python cudf.Series.max用法及代码示例
- Python cmath.isclose()用法及代码示例
- Python cmp()用法及代码示例
- Python cudf.DatetimeIndex.dayofweek用法及代码示例
- Python cudf.DataFrame.apply用法及代码示例
注:本文由纯净天空筛选整理自python.org大神的英文原创作品 ctypes.Structure._fields_。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。