Learn of dictionary,
simple example of dictionary in  “Simple Python tutorial"
--------------------------------------------------------- #!/usr/bin/python
# Filename:dictionary.py # 'ab' is short for 'a'ddress'b'ook ab = { 'Swaroop' : 'swaroop@byteofpython.info',
'Larry' : 'larry@wall.org',
'Matsumoto' : 'matz@ruby-lang.org',
'Spammer' : 'spammer@hotmail.com' } print "Swaroop's address is %s" %ab['Swaroop'] # delete a key->value pair del ab['Spammer'] print '\nThere are %d contacts in the address-book\n' %len(ab)
for name,address in ab.items():
print 'Contact %s at %s' %(name,address) if 'Guido' in ab:
print "\nGuido's address is %s" %ab['Guido'] if ab.has_key('Larry'):
print "\nLarry's address is %s" %ab['Larry']

dictionary ----- python的更多相关文章

  1. Python内置数据类型之Dictionary篇

    1.查看函数XXX的doc string. Python的函数是有属性的,doc string便是函数的属性.所以查看函数XXX的属性的方法是模块名.XXX.__doc__ 2.模块的属性 每个模块都 ...

  2. [Python]字典Dictionary、列表List、元组Tuple差异化理解

    概述:Python中这三种形式的定义相近,易于混淆,应注意区分. aDict={'a':1, 'b':2, 'c':3, 'd':4, 'e':5} aList=[1,2,3,4,5] aTuple= ...

  3. Python基础入门教程

    Python基础入门教程 Python基础教程 Python 简介 Python环境搭建 Python 基础语法 Python 变量类型 Python 运算符 Python 条件语句 Python 循 ...

  4. python常见的特异点

    编码问题 Python中默认的编码格式是 ASCII 格式,在没修改编码格式时无法正确打印汉字,所以在读取中文时会报错.解决方法为只要在文件开头加入 # -*- coding: UTF-8 -*- 或 ...

  5. Python人工智能学习笔记

    Python教程 Python 教程 Python 简介 Python 环境搭建 Python 中文编码 Python 基础语法 Python 变量类型 Python 运算符 Python 条件语句 ...

  6. python 笔记-转

    python笔记   Python 学习笔记 - 14.技巧(Tips)   Python 学习笔记 - 13.异常(Exception)   Python 学习笔记 - 12.流程控制(Contro ...

  7. python总结--目录(转)

    python模块   [Python]随机数与随机字符串  举例说明Python的CSV模块   python模块之smtplib: 用python发送SSL/TLS安全邮件   python模块之e ...

  8. A Complete Tutorial to Learn Data Science with Python from Scratch

    A Complete Tutorial to Learn Data Science with Python from Scratch Introduction It happened few year ...

  9. Python 变量 (上)

    Python通过变量引用内存中的值,变量的值占用多少空间是由变量的类型决定的.声明变量不需要指定变量的类型,解释器会自动根据值来判断.变量名称必须符合标识符的定义 标识符 标识符是由字母,数字和下划线 ...

随机推荐

  1. 用CRTP在C++中实现静态函数的多态

    我上一篇博客[C++的静态分发(CRTP)和动态分发(虚函数多态)的比较](http://www.cnblogs.com/fresky/p/3504241.html)介绍了如何用CRTP(Curiou ...

  2. [置顶] sqlplus 使用笔记

    关于sqlplus常用命令的一些记录 这两天去参加了一个关于orcale 12C release1的技术交流会,主要关注的是orcale Spatial 在12C上面的一些新的变化,一起交流的有学校的 ...

  3. MVC中一般为什么用IQueryable而不是用IList

    IList(IList<T>)会立即在内存里创建持久数据,这就没有实现“延期执行(deferred execution)”,如果被加载的实体有关联实体(associations),此关联实 ...

  4. 第三篇——第二部分——第五文 配置SQL Server镜像——域环境SQL Server镜像日常维护

    本文接上面两篇搭建镜像的文章: 第三篇--第二部分--第三文 配置SQL Server镜像--域环境:http://blog.csdn.net/dba_huangzj/article/details/ ...

  5. BZOJ 3265 志愿者招募增强版 单

    标题效果:同1061 只是间隔为每种类型的志愿工作是多级 这是卡网络流量?未知 所有在所有的1061您将可以更改为在稍微改变- - #include <cmath> #include &l ...

  6. keepalive support-----Programming applications

    TCP Keepalive HOWTO Prev   Next 4. Programming applications This section deals with programming code ...

  7. Linux下查看系统配置

    CPU 1. lscpu:显示cpu架构信息 [xxx@localhost ~]$ lscpu Architecture: x86_64 CPU op-mode(s): -bit, -bit Byte ...

  8. Base64工具类

    public final class AbBase64 { /** The Constant base64EncodeChars. */ private static final char[] bas ...

  9. ASP.NET分页存储过程,解决搜索时丢失条件信息

    存储过程: -- ============================================= -- Author: -- Create date: -- Description: 分页 ...

  10. node express

    在某QQ群里,发现大家都在搞node,为了不被out,这周主要研究了一下,还挺高大上. 参考了下资料,适合初学者学习. Node和NPM的安装够便捷了,不细说...有几点基础顺手提一下: 安装命令中的 ...