# 學(xué)習(xí)字典;創(chuàng)建字典,刪除某一項,增加某一項,遍歷字典并演示;查找字典是否有存在這個值;
# 'ab'是地址(Address)簿(book)的縮寫
ab = {
'Swaroop' :'swaroop@qq.com',
'Larry' :'larry@163.com',
'Matsumoto':'matsumoto@aliyun.com',
'Spammer' : 'spammer@sina.com'
}
print("Swaroop's address is",ab['Swaroop'] )
#刪除一對鍵值
del ab['Spammer']
print('\n There are {} contacts in the address-book \n'.format(len(ab)))
for name,address in ab.items():
print('Contace {} at {}'.format(name,address))
#添加一組
ab['Guido'] = 'guido@gmail.com'
if 'Guido' in ab:
print("\nGuido's address is ",ab['Guido'])