标签:click c4c event item print key值 hide span closed
1、遍历key值
>>> a {‘a‘: ‘1‘, ‘b‘: ‘2‘, ‘c‘: ‘3‘} >>> for key in a: print(key+‘:‘+a[key]) a:1 b:2 c:3 >>> for key in a.keys(): print(key+‘:‘+a[key]) a:1 b:2 c:3
2、使用字典自带函数values()、items()。
(1)使用values()遍历
>>> for value in a.values(): print(value) 1 2 3
(2)使用items()遍历
>>> for kv in a.items(): print(kv) (‘a‘, ‘1‘) (‘b‘, ‘2‘) (‘c‘, ‘3‘)
>>> for key,value in a.items(): print(key+‘:‘+value) a:1 b:2 c:3 >>> for (key,value) in a.items(): print(key+‘:‘+value) a:1 b:2 c:3
标签:click c4c event item print key值 hide span closed
原文地址:https://www.cnblogs.com/karrya/p/10846452.html