這裏是字典我有爲什麼python像我這樣的詞典排序?
propertyList = {
"id": "int",
"name": "char(40)",
"team": "int",
"realOwner": "int",
"x": "int",
"y": "int",
"description": "char(255)",
"port": "bool",
"secret": "bool",
"dead": "bool",
"nomadic": "bool",
"population": "int",
"slaves": "int",
}
但是,當我把它打印出來爲「\ n」。加入(myDict)我得到這個
name
nomadic
dead
port
realOwner
secret
slaves
team
y
x
population
id
description
我知道,一個字典是無序的,但它每次都是一樣的,我不知道爲什麼。
無序意味着順序是關你的事。這並不意味着訂單不一致。 – 2009-02-09 00:11:53
@S。洛特:確切地說。這就是我在CS課程中教過的東西 - 「無序集合總是有一定的順序,*無序*意味着我們不應該依賴它' – Abgan 2009-02-09 09:25:37