用法:
_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_。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。