python中的 dict() 函数
dict() 函数函数语法: dict(key/value)
参数说明:
- key/value -- 用于创建字典的键/值对,此处可以表示键/值对的方法有很多,请看实例。
实例
以下实例展示了 dict() 函数的使用方法:
# !/usr/bin/python3
dict0 = dict() # 传一个空字典
print('dict0:', dict0) dict1 = dict({'three': 3, 'four': 4}) # 传一个字典
print('dict1:', dict1) dict2 = dict(five=5, six=6) # 传关键字
print('dict2:', dict2) dict3 = dict([('seven', 7), ('eight', 8)]) # 传一个包含一个或多个元祖的列表
print('dict3:', dict3) dict5 = dict(zip(['eleven', 'twelve'], [11, 12])) # 传一个zip()函数
print('dict5:', dict5)
以上实例输出结果为:
dict0: {}
dict1: {'four': 4, 'three': 3}
dict2: {'five': 5, 'six': 6}
dict3: {'seven': 7, 'eight': 8}
dict5: {'twelve': 12, 'eleven': 11}
python中的 dict() 函数的更多相关文章
- python --- Python中的callable 函数
python --- Python中的callable 函数 转自: http://archive.cnblogs.com/a/1798319/ Python中的callable 函数 callabl ...
- python中使用zip函数出现<zip object at 0x02A9E418>
在Python中使用zip函数,出现<zip object at 0x02A9E418>错误的原因是,你是用的是python2点多的版本,python3.0对python做了改动 zip方 ...
- [转载]python中multiprocessing.pool函数介绍
原文地址:http://blog.sina.com.cn/s/blog_5fa432b40101kwpi.html 作者:龙峰 摘自:http://hi.baidu.com/xjtukanif/blo ...
- Python 中的isinstance函数
解释: Python 中的isinstance函数,isinstance是Python中的一个内建函数 语法: isinstance(object, classinfo) 如果参数object是cla ...
- Python中的map()函数和reduce()函数的用法
Python中的map()函数和reduce()函数的用法 这篇文章主要介绍了Python中的map()函数和reduce()函数的用法,代码基于Python2.x版本,需要的朋友可以参考下 Py ...
- python中multiprocessing.pool函数介绍_正在拉磨_新浪博客
python中multiprocessing.pool函数介绍_正在拉磨_新浪博客 python中multiprocessing.pool函数介绍 (2010-06-10 03:46:5 ...
- 举例详解Python中的split()函数的使用方法
这篇文章主要介绍了举例详解Python中的split()函数的使用方法,split()函数的使用是Python学习当中的基础知识,通常用于将字符串切片并转换为列表,需要的朋友可以参考下 函数:sp ...
- python中的生成器函数是如何工作的?
以下内容基于python3.4 1. python中的普通函数是怎么运行的? 当一个python函数在执行时,它会在相应的python栈帧上运行,栈帧表示程序运行时函数调用栈中的某一帧.想要获得某个函 ...
- python中的map()函数
MapReduce的设计灵感来自于函数式编程,这里不打算提MapReduce,就拿python中的map()函数来学习一下. 文档中的介绍在这里: map(function, iterable, .. ...
随机推荐
- Excel-查找函数
1.VLOOKUP函数 该函数的语法规则如下: VLOOKUP(lookup_value,table_array,col_index_num,range_lookup) 多表关联查询---vlooku ...
- Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4) 题解
Happy Birthday, Polycarp! Make Them Odd As Simple as One and Two Let's Play the Words? Two Fairs Bea ...
- Linux ssh 密钥创建与验证
1.需要两个虚拟机,每一个创建一个用户登录到用户根下 2.每个用户都要创建密钥对 3.把两个用户的公用密钥用ssh-copy-id -i 命令将公用的密钥复制到另一个用户中 4.在客户端开 ...
- [LeetCode] 902. Numbers At Most N Given Digit Set 最大为 N 的数字组合
We have a sorted set of digits D, a non-empty subset of {'1','2','3','4','5','6','7','8','9'}. (Not ...
- Office 2016正式版/2019预览版 使用注意
改写状态已经被隐藏 右击Word状态栏可以看到改写是否打开
- Codeforces 1204D Kirk and a Binary String - 数学
题目传送门 传送门 群除我均会猜结论/找规律,sad.... 以下内容只保证代码能过system test,证明应该都是在纯口胡 约定下文中的$LIS$表示最长不下降子序列. 定义$zero(s)$表 ...
- ng的动画过渡
动画过渡两种方法 1.使用angular+animation实现 在app-module.ts中引入 BrowserAnimationsModule 1.import { BrowserAnimati ...
- Windows 配置网络文件夹映射
mklink /D D:\temp\pythonmxds2 \\192.168.190.186\bigdata\kaoyanmxds
- 常见框架和WSGI协议
三大框架对比 Django 大而全 自带的功能特别特别多 类似于航空母舰 有时候过于笨重 Flask 小而精,只保留了核心功能,其他可以自由选择 第三方的模块特别特别多,如果将flask第三方模块全部 ...
- 前端学习:学习笔记(JS部分)
前端学习:学习笔记(JS部分) 前端学习:JS学习总结(图解) JS的简介 JS基本语法 JS内置对象 JS的函数 JS的事件 JS的BOM JS的DOM JS的简介 新建步骤 <body ...