标签:链接 ems 等价 values tps bar http title pre
>>> 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
在使用上,for key in a和 for key in a.keys():完全等价。
>>> for value in a.values(): print(value) 1 2 3
(3)遍历字典项
>>> for kv in a.items(): print(kv) (‘a‘, ‘1‘) (‘b‘, ‘2‘) (‘c‘, ‘3‘)
(4)遍历字典健值
>>> 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
在使用上for key,value in a.items()与for (key,value) in a.items()完全等价
参考链接:https://www.cnblogs.com/stuqx/p/7291948.html
标签:链接 ems 等价 values tps bar http title pre
原文地址:https://www.cnblogs.com/xiohao/p/11241506.html