numpy-dictionary

d ={'peter': 'handsome', 'shutong':'cute'}#key:value
print('peter' in d)#is in ?
print(d['peter'])#下標訪問內容
d['1']='11'
print(d['1'])
print(d['shutong'])
del d['1']
print('1' in d)

f = {'person':2, 'dog':4, 'man':3}

for  animals in f:
    legs = f[animals]
    print('a %s has %d legs'%(animals, legs))
    print('a %s has %d legs',(animals, legs))

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章