zoukankan      html  css  js  c++  java
  • Python函数 dict()

     dict()

    作用:dict() 函数用于创建一个字典。返回一个字典。

    语法:

    class dict(**kwarg)
    class dict(mapping, **kwarg)
    class dict(iterable, **kwarg)

    参数说明:

    • **kwargs -- 关键字
    • mapping -- 元素的容器。
    • iterable -- 可迭代对象

    实例:

    1 >>>dict()                        # 创建空字典
    2 {}
    3 >>> dict(a='a', b='b', t='t')     # 传入关键字
    4 {'a': 'a', 'b': 'b', 't': 't'}
    5 >>> dict(zip(['one', 'two', 'three'], [1, 2, 3]))   # 映射函数方式来构造字典
    6 {'three': 3, 'two': 2, 'one': 1} 
    7 >>> dict([('one', 1), ('two', 2), ('three', 3)])    # 可迭代对象方式来构造字典
    8 {'three': 3, 'two': 2, 'one': 1}
    9 >>>
  • 相关阅读:
    学习Faster R-CNN代码roi_pooling(二)
    应用安全
    应用安全
    应用安全
    应用安全
    应用安全
    红队
    应用安全
    应用安全
    应用安全
  • 原文地址:https://www.cnblogs.com/guyuyuan/p/6952442.html
Copyright © 2011-2022 走看看