Python辞書の使用
1512 ワード
#!/usr/bin/python
ab={ 'jack' : '[email protected]', 'ken' : '[email protected]', 'hellen' : '[email protected]' } print 'jack address is %s' % ab['jack'] ab['sten']='[email protected]'
del ab['ken'] print '
THere are %d conntacts in the address-book
' % len(ab) for name,address in ab.items(): print 'Contact %s at %s' % (name,address) if 'sten' in ab: print 'yes
'
else: print 'No
'