Python 字典 Print 格式化

__author__ = 'dell'

ab = {'Swaroop': 'swaroopch@byteofpython.info', 'Larry': 'larry@wall.org', 'Matsumoto': 'matz@ruby-lang.org',
      'Spammer': 'spammer@hotmail.com'}

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

# add a key/value pair
ab['Guido'] = 'guido@python.org'

del ab['Spammer']

print "
there is %d contacts in the address-book
" % len(ab)
for name, address in ab.items():
    print 'contact %s at %s' % (name, address)
    
if 'Guido' in ab:
    print "
 Guido's address is %s" % ab["Guido"]
原文地址:https://www.cnblogs.com/i80386/p/3238533.html