Python 字典 Print 格式化

__author__ = 'dell'

ab = {'Swaroop': '[email protected]', 'Larry': '[email protected]', 'Matsumoto': '[email protected]',
      'Spammer': '[email protected]'}

print "Swaroop's address is %s" % ab['Swaroop']

# add a key/value pair
ab['Guido'] = '[email protected]'

del ab['Spammer']

print "\nthere is %d contacts in the address-book\n" % len(ab)
for name, address in ab.items():
    print 'contact %s at %s' % (name, address)
    
if 'Guido' in ab:
    print "\n Guido's address is %s" % ab["Guido"]

 

你可能感兴趣的:(Python 字典 Print 格式化)