• 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
  • 相关阅读:
    表单提交
    后台返回来的数据是字符串
    背景图充满屏幕
    微信小程序添加模板消息
    axios
    前端常见的跨域解决方案
    gulp的压缩
    git的使用步骤
    vue项目使用mint UI
    利用HBuilder将vue项目打包成移动端app
  • 原文地址:https://www.cnblogs.com/gundan/p/8149442.html
Copyright © 2020-2023  润新知