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 "\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"]