python dict()函数(用于创建一个字典)
生活随笔
收集整理的這篇文章主要介紹了
python dict()函数(用于创建一个字典)
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
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從映射對(duì)象的(鍵,值)對(duì)初始化的新字典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)使用關(guān)鍵字參數(shù)列表中的“名稱(chēng)=值”對(duì)初始化的新字典。 例如:dict(one = 1,two = 2)# (copied from class doc)"""pass示例:
以下實(shí)例展示了 dict 的使用方法:
參考文章1:Python dict() 函數(shù)
參考文章2:python zip類(lèi) (將對(duì)象中對(duì)應(yīng)的元素打包成若干元組,返回由這些若干元組組成的對(duì)象,節(jié)省內(nèi)存)
總結(jié)
以上是生活随笔為你收集整理的python dict()函数(用于创建一个字典)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: pycharm导入(import)报红(
- 下一篇: indexes和indices的区别(下