我這么使用時提示說“找不到Sentence_link”
```
class Sentence_link(ctypes.Structure):
_fields_= [("para_idx", ctypes.c_ulong), ("sent_idx", ctypes.c_ulong),("sent_init",ctypes.c_int),("msg_buff",ctypes.c_char_p), ("next",ctypes.POINTER(Sentence_link))]
```
```
_fields_= [("para_idx", ctypes.c_ulong), ("sent_idx", ctypes.c_ulong),("sent_init",ctypes.c_int),("msg_buff",ctypes.c_char_p), ("next",ctypes.POINTER(Sentence_link))]
NameError: name 'Sentence_link' is not defined
```
請問該如何參考自身?
uj5u.com熱心網友回復:
因為新的類 單元格在類陳述句本身中不可用。在ctypes中,我們可以 在類陳述句之后定義單元格類并設定_fields_屬性類似這樣寫
#重構struct list_head結構體
(+pass 定義的時候另起一行)
class list_head(ctypes.Structure):
pass
list_head._fields_ = [("next",POINTER(list_head)),("prev",POINTER(list_head))]
uj5u.com熱心網友回復:
https://blog.csdn.net/nb_zsy/article/details/104836310轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/114549.html
標籤:工具平臺和程序庫
