python 字典 dict items values keys
dict.items()
1 >>> d = dict(one=1,two=2) 2 >>> it1 = d.items() 3 >>> it1 4 dict_items([('one', 1), ('two', 2)]) 5 >>> type(it1) 6 <class 'dict_items'> 7 >>> from collections import Iterable 8 >>> from collections import Iterator 9 >>> isinstance(it1, Iterable) 10 True 11 >>> isinstance(it1, Iterator) 12 False
dict.values()
1 >>> d = dict(one=1, two=2) 2 >>> values = d.values() 3 >>> values 4 dict_values([1, 2]) 5 >>> type(values) 6 <class 'dict_values'> 7 >>> from collections import Iterable 8 >>> from collections import Iterator 9 >>> isinstance(values, Iterable) 10 True 11 >>> isinstance(values, Iterator) 12 False
dict.keys()
1 >>> d = dict(one=1, two=2) 2 >>> keys = d.keys() 3 >>> keys 4 dict_keys(['one', 'two']) 5 >>> type(keys) 6 <class 'dict_keys'> 7 >>> from collections import Iterable 8 >>> from collections import Iterator 9 >>> isinstance(values, Iterable) 10 True 11 >>> isinstance(values, Iterator) 12 False