python篇历字典中的值 - 编程语言

博主:xiaoweixiaowei 2023-01-18 条评论
>>> 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
>>> 

The End

发布于:2023-01-18,除非注明,否则均为 主机评测原创文章,转载请注明出处。