python dict()函数(用于创建一个字典)
生活随笔
收集整理的這篇文章主要介紹了
python dict()函数(用于创建一个字典)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
from builtins.py
def __init__(self, seq=None, **kwargs): # known special case of dict.__init__"""dict() -> new empty dictionary 新的空字典dict(mapping) -> new dictionary initialized from a mapping object's(key, value) pairs從映射對象的(鍵,值)對初始化的新字典dict(iterable) -> new dictionary initialized as if via:d = {}for k, v in iterable:d[k] = vdict(**kwargs) -> new dictionary initialized with the name=value pairsin the keyword argument list. For example: dict(one=1, two=2)使用關鍵字參數列表中的“名稱=值”對初始化的新字典。 例如:dict(one = 1,two = 2)# (copied from class doc)"""pass示例:
以下實例展示了 dict 的使用方法:
參考文章1:Python dict() 函數
參考文章2:python zip類 (將對象中對應的元素打包成若干元組,返回由這些若干元組組成的對象,節省內存)
總結
以上是生活随笔為你收集整理的python dict()函数(用于创建一个字典)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: pycharm导入(import)报红(
- 下一篇: indexes和indices的区别(下