Python 官方文档:入门教程 => 点击学习
python中是存在dict函数的,dict()函数的作用是用于创建一个字典。dict()函数语法:class dict(**kwarg)class dict(mapping, **kwarg)class&nb
python中是存在dict函数的,dict()函数的作用是用于创建一个字典。
dict()函数语法:
class dict(**kwarg)class dict(mapping, **kwarg)
class dict(iterable, **kwarg)
参数说明:
**kwargs:关键字;
mapping:元素的容器;
iterable:可迭代对象;
dict()函数使用方法:
>>>dict() # 创建空字典{}
>>> dict(a='a', b='b', t='t') # 传入关键字
{'a': 'a', 'b': 'b', 't': 't'}
>>> dict(zip(['one', 'two', 'three'], [1, 2, 3])) # 映射函数方式来构造字典
{'three': 3, 'two': 2, 'one': 1}
>>> dict([('one', 1), ('two', 2), ('three', 3)]) # 可迭代对象方式来构造字典
{'three': 3, 'two': 2, 'one': 1}
>>>
--结束END--
本文标题: python中为什么没有dict函数
本文链接: https://www.lsjlt.com/news/113974.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0