Mega Code Archive

 
Categories / Python Tutorial / Dictionary
 

To access individual dictionary elements, you use the familiar square brackets along with the key to obtain its value

dict2 = {'name': 'earth', 'port': 80} dict2['name'] print 'host %s is running on port %d' % (dict2['name'], dict2['port'])