# 1. ###########
# Dictionary(Dict)
##############
#初始方式
tDict = {} 


# 新增value的方式,必須定義index-key, 此處為tKey1,tKey2
tDict["tKey1"] = "123456"
tDict["tKey2"] = "999999" 


#輸出tDict的結果
print tDict
-----------------------------------
{'tKey2': '999999', 'tKey1': '123456'}
-----------------------------------

  

# 2. ###########
# List
##############
#初始方式
tList = [] 


# 新增value的方式,使用append,直接插入後面
tList.append("123456")
tList.append("999999")

 
#輸出tList的結果
print tList
-----------------------------------
['123456', '999999']
-----------------------------------

 
# 新增value的方式,使用insert,直接插入指定位置
tList.insert(1, "I am 1")

 

#輸出tList的結果
print tList
-----------------------------------
['123456', 'I am 1', '999999']
-----------------------------------

 
# 新增value的方式,使用insert,直接插入指定位置
tList.insert(0, "I am 0")
-----------------------------------
['I am 0', '123456', 'I am 1', '999999']
-----------------------------------

arrow
arrow
    全站熱搜

    dreamtails 發表在 痞客邦 留言(0) 人氣()