Python 字典的使用
#!/usr/bin/python
ab={ 'jack' : 'jack@1.com',
'ken' : 'ken@1.com',
'hellen' : 'hellen@1.com'
}
print 'jack address is %s' % ab['jack']
ab['sten']='sten@1.com'
del ab['ken']
print '\nTHere are %d conntacts in the address-book\n' % len(ab)
for name,address in ab.items():
print 'Contact %s at %s' % (name,address)
if 'sten' in ab:
print 'yes\n'
else:
print 'No\n'