作者d5528300 (Chen)
站內Python
標題[問題] 類似C的structure array
時間Wed Sep 10 11:18:07 2014
各位大大好
小弟是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://webptt.com/m.aspx?n=bbs/Python/M.1410319090.A.CFF.html
1F:推 timTan: 思維不同 09/10 11:59
2F:→ timTan: Python 內你要放啥都行 09/10 12:00
3F:→ d5528300: 恩恩 這點我大概了解 我是想問說list裡面要放一個結構 09/10 12:25
4F:→ d5528300: 一定要用class還是說可以用其他方式宣告 09/10 12:26
5F:推 eight0: 可以用字典或是 namedtuple 09/10 12:47
6F:→ Debians: 裡面放什麼型別都行,不像C那種強型別 可以多看sample co 09/10 20:39
7F:→ Debians: de 熟悉這類語言的思維 09/10 20:39
8F:推 timTan: 你的問題,應該是寫 Python 的人怎麼使用結構 09/12 15:04
9F:→ timTan: Nametuple, tuple, dict, class 都是選項。 09/12 15:04
10F:→ cybelia: Array[3]['id']=... 之類的 09/13 12:39
11F:→ d5528300: 感謝!! 09/15 19:18