0X07遍历字典
# -*- coding:utf-8 -*- #!/usr/bin/python ''' 一;遍历字典 ''' ''' 1;遍历所有的建---值对 ''' user_0 = { 'username' : 'aaorn', 'first' : 'wang', 'last' : 'tao' } for key,value in user_0.items(): print("key: " + key ) print("value: " + value + '\n')
# -*- coding:utf-8 -*- #!/usr/bin/python ''' 一;遍历字典 ''' ''' 1;按顺序遍历字典中的所有的建 ''' user_0 = { 'username' : 'aaorn', 'first' : 'wang', 'last' : 'tao' } for key in user_0.keys(): print(key) print('\n') for key in sorted(user_0.keys()): print(key)
# -*- coding:utf-8 -*- #!/usr/bin/python ''' 一;遍历字典 ''' ''' 1;遍历字典中的所有值 ''' user_0 = { 'username' : 'aaorn', 'first' : 'wang', 'last' : 'tao' } for key in user_0.values(): print(key) print('\n') for key in sorted(user_0.values()): print(key)