Python标准库:内置函数dict(mapping, **kwarg)
2017-08-08 08:17
309 查看
本函数是从一个映射函数对象构造一个新字典。
与dict(**kwarg)函数不一样的地方是參数输入是一个映射类型的函数对象,比方zip函数、map函数。
样例:
输出结果例如以下:
{'a': 3, 'one': 1, 'two': 2}
{'three': 3, 'two': 2, 'one': 1}
蔡军生 QQ:9073204 深圳
与dict(**kwarg)函数不一样的地方是參数输入是一个映射类型的函数对象,比方zip函数、map函数。
样例:
#dict() #以键对方式构造字典 d1 = dict(one = 1, two = 2, a = 3) print(d1) #以映射函数方式来构造字典 d2 = dict(zip(['one', 'two', 'three'], [1, 2, 3])) print(d2)
输出结果例如以下:
{'a': 3, 'one': 1, 'two': 2}
{'three': 3, 'two': 2, 'one': 1}
蔡军生 QQ:9073204 深圳
相关文章推荐
- Python标准库:内置函数dict(mapping, **kwarg)
- Python标准库:内置函数dict(mapping, **kwarg)
- Python标准库:内置函数dict(iterable, **kwarg)
- Python标准库:内置函数dict(iterable, **kwarg)
- Python标准库:内置函数dict(**kwarg)
- Python标准库:内置函数dict(**kwarg)
- Python标准库:内置函数dict(**kwarg)
- Python标准库:内置函数dict(iterable, **kwarg)
- Python标准库:内置函数all(iterable)
- Python标准库:内置函数zip(*iterables)
- Python标准库:内置函数len(s)
- python笔记31-使用ddt报告出现dict() -> new empty dictionary dict(mapping) 问题解决
- Python标准库:内置函数eval(expression, globals=None, locals=None)
- Python标准库:内置函数bytearray([source[, encoding[, errors]]])
- Python标准库:内置函数vars([object])
- Python标准库:内置函数int(x, base=10)
- Python标准库:内置函数isinstance(object, classinfo)
- Python标准库:内置函数len(s)
- Python标准库:内置函数map(function, iterable, ...)
- Python标准库:内置函数vars([object])