标签:value host name val 字典 run python pytho earth
>>> dict1 = {‘name‘: ‘earth‘, ‘port‘: 80}         
>>> for key in dict1:                             
...     print ‘key=%s,value=%s‘ % (key,dict1[key])
... 
key=name,value=earth
key=port,value=80
>>> dict1[‘name‘]
‘earth‘
>>> print ‘host %s is running on port %d‘ % (dict1[‘name‘],dict1[‘port‘])
host earth is running on port 80
>>> 标签:value host name val 字典 run python pytho earth
原文地址:http://blog.51cto.com/yht1990/2144367