用法:
_anonymous_
列出未命名(匿名)字段名稱的可選序列。
_anonymous_
必須在分配_fields_
時已經定義,否則無效。此變量中列出的字段必須是結構或聯合類型字段。
ctypes
將在允許直接訪問嵌套字段的結構類型中創建說明符,而無需創建結構或聯合字段。這是一個示例類型(Windows):
class _U(Union): _fields_ = [("lptdesc", POINTER(TYPEDESC)), ("lpadesc", POINTER(ARRAYDESC)), ("hreftype", HREFTYPE)] class TYPEDESC(Structure): _anonymous_ = ("u",) _fields_ = [("u", _U), ("vt", VARTYPE)]
TYPEDESC
結構說明了一種 COM 數據類型,vt
字段指定聯合字段中的哪一個是有效的。由於u
字段被定義為匿名字段,因此現在可以直接從 TYPEDESC 實例訪問成員。td.lptdesc
和td.u.lptdesc
是等價的,但前者更快,因為它不需要創建臨時聯合實例:td = TYPEDESC() td.vt = VT_PTR td.lptdesc = POINTER(some_type) td.u.lptdesc = POINTER(some_type)
相關用法
- Python ctypes.Structure._fields_用法及代碼示例
- 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._anonymous_。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。