class dict(**kwargs)

返回一个字典。本方法用来创建一个字典对象。
只能传入一个参数。

>>> dict(a=1)
{'a': 1}
也可以传入映射函数作为参数
>>> dict(zip(['a','b'],[1,2]))
{'a': 1, 'b': 2}
也可以传入可迭代对象作为参数
>>> dict([('a',1),('b',2)])
{'a': 1, 'b': 2}
还可以传入迭代器
>>> h = ['hello']
>>> a = ((i,[]) for i in h)
>>> isinstance(a,Iterator)
True
>>> dict(a)
{'hello': []}

python内置函数之dict()的更多相关文章

  1. Python内置函数(23)——dict

    英文文档: class dict(**kwarg) class dict(mapping, **kwarg) class dict(iterable, **kwarg) Return a new di ...

  2. Python内置函数(15)——dict

    英文文档: class dict(**kwarg) class dict(mapping, **kwarg) class dict(iterable, **kwarg) Return a new di ...

  3. python 内置函数和函数装饰器

    python内置函数 1.数学相关 abs(x) 取x绝对值 divmode(x,y) 取x除以y的商和余数,常用做分页,返回商和余数组成一个元组 pow(x,y[,z]) 取x的y次方 ,等同于x ...

  4. Python 内置函数笔记

    其中有几个方法没怎么用过, 所以没整理到 Python内置函数 abs(a) 返回a的绝对值.该参数可以是整数或浮点数.如果参数是一个复数,则返回其大小 all(a) 如果元组.列表里面的所有元素都非 ...

  5. 【转】python 内置函数总结(大部分)

    [转]python 内置函数总结(大部分) python 内置函数大讲堂 python全栈开发,内置函数 1. 内置函数 python的内置函数截止到python版本3.6.2,现在python一共为 ...

  6. python内置函数,匿名函数

    一.匿名函数 匿名函数:为了解决那些功能很简单的需求而设计的一句话函数 def calc(n): return n**n print(calc(10)) #换成匿名函数 calc = lambda n ...

  7. python 内置函数总结(大部分)

    python 内置函数大讲堂 python全栈开发,内置函数 1. 内置函数 python的内置函数截止到python版本3.6.2,现在python一共为我们提供了68个内置函数.它们就是pytho ...

  8. Python之路(第八篇)Python内置函数、zip()、max()、min()

    一.python内置函数 abs() 求绝对值 例子 print(abs(-2)) all() 把序列中每一个元素做布尔运算,如果全部都是true,就返回true, 但是如果是空字符串.空列表也返回t ...

  9. python内置函数大全(分类)

    python内置函数大全 python内建函数 最近一直在看python的document,打算在基础方面重点看一下python的keyword.Build-in Function.Build-in ...

随机推荐

  1. [Android 新特性] Android 4.3新功能(正式发布前)

    腾讯数码讯(编译:徐萧梓丞)虽然谷歌公司目前尚未正式对外发布最新的Android 4.3果冻豆操作系统,但是在上周我们已经看到了关于三星正 在为原生版Galaxy S4进行Android 4.3系统进 ...

  2. django:MySQL Strict Mode is not set for database connection 'default'

    ?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default'        HINT: MySQL's ...

  3. python的单元测试框架

    1.unittest是Python内置的标准类库.它的API跟Java的JUnit..net的NUnit,C++的CppUnit很相似.   通过继承unittest.TestCase来创建一个测试用 ...

  4. sqlmap的篡改绕过WAF

    space2comment.py Replaces space character (‘ ‘) with comments ‘/**/’ Example: * Input: SELECT id FRO ...

  5. JS 与Flex交互:html中的js 与flex中的actionScript通信

    Flex与JavaScript交互的问题,这里和大家分享一下,主要包括Flex调用JavaScript中的函数和JavaScript调用Flex中的函数两大部分内容. Flex 与JavaScript ...

  6. 当Intellij IDEA 遇到 Mac

    当Intellij IDEA 遇到 Mac alt+insert变为control+N

  7. 转: SSH 公钥认证

    转: http://blog.knownsec.com/2012/05/ssh-%E5%85%AC%E9%92%A5%E8%AE%A4%E8%AF%81/ SSH 公钥认证 2012-05-15 简介 ...

  8. 修改ubuntu下网卡名不是eth0的问题

    sudo nano /etc/default/grub 找到GRUB_CMDLINE_LINUX=""改为GRUB_CMDLINE_LINUX="net.ifnames= ...

  9. 10个CSS简写技巧让你永远受用

    转自:http://blog.bingo929.com/10-css-shorthand-tips.html 前言: CSS简写就是指将多行的CSS属性声明化成一行,又称为CSS代码优化.CSS简写的 ...

  10. 显示游戏FPS帧率的几种计算方式

    FPSDisplay.cs using UnityEngine; using System.Collections; public class FPSDisplay : MonoBehaviour { ...