看板 Python 關於我們 聯絡資訊
各位大大好 小弟是python初學者 想要請問在python 要怎麼做一個類似下面C語言的structure array typedef struct array_list { int id; int data; char name[16][2]; } array_list; array_list Array[10]; 爬文後還是沒有非常懂... 請問是要用一個class去宣告 再來把他加到list上面嗎? 還是有其他方法 謝謝各位!!! -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.34.222.59 ※ 文章網址: http://www.ptt.cc/bbs/Python/M.1410319090.A.CFF.html
timTan: 思維不同 09/10 11:59
timTan: Python 內你要放啥都行 09/10 12:00
d5528300: 恩恩 這點我大概了解 我是想問說list裡面要放一個結構 09/10 12:25
d5528300: 一定要用class還是說可以用其他方式宣告 09/10 12:26
eight0: 可以用字典或是 namedtuple 09/10 12:47
Debians: 裡面放什麼型別都行,不像C那種強型別 可以多看sample co 09/10 20:39
Debians: de 熟悉這類語言的思維 09/10 20:39
timTan: 你的問題,應該是寫 Python 的人怎麼使用結構 09/12 15:04
timTan: Nametuple, tuple, dict, class 都是選項。 09/12 15:04
cybelia: Array[3]['id']=... 之類的 09/13 12:39
d5528300: 感謝!! 09/15 19:18