dictionary ----- python
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的更多相关文章
- Python内置数据类型之Dictionary篇
1.查看函数XXX的doc string. Python的函数是有属性的,doc string便是函数的属性.所以查看函数XXX的属性的方法是模块名.XXX.__doc__ 2.模块的属性 每个模块都 ...
- [Python]字典Dictionary、列表List、元组Tuple差异化理解
概述:Python中这三种形式的定义相近,易于混淆,应注意区分. aDict={'a':1, 'b':2, 'c':3, 'd':4, 'e':5} aList=[1,2,3,4,5] aTuple= ...
- Python基础入门教程
Python基础入门教程 Python基础教程 Python 简介 Python环境搭建 Python 基础语法 Python 变量类型 Python 运算符 Python 条件语句 Python 循 ...
- python常见的特异点
编码问题 Python中默认的编码格式是 ASCII 格式,在没修改编码格式时无法正确打印汉字,所以在读取中文时会报错.解决方法为只要在文件开头加入 # -*- coding: UTF-8 -*- 或 ...
- Python人工智能学习笔记
Python教程 Python 教程 Python 简介 Python 环境搭建 Python 中文编码 Python 基础语法 Python 变量类型 Python 运算符 Python 条件语句 ...
- python 笔记-转
python笔记 Python 学习笔记 - 14.技巧(Tips) Python 学习笔记 - 13.异常(Exception) Python 学习笔记 - 12.流程控制(Contro ...
- python总结--目录(转)
python模块 [Python]随机数与随机字符串 举例说明Python的CSV模块 python模块之smtplib: 用python发送SSL/TLS安全邮件 python模块之e ...
- 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 ...
- Python 变量 (上)
Python通过变量引用内存中的值,变量的值占用多少空间是由变量的类型决定的.声明变量不需要指定变量的类型,解释器会自动根据值来判断.变量名称必须符合标识符的定义 标识符 标识符是由字母,数字和下划线 ...
随机推荐
- php 获取某个月的周次信息
在做统计的时候如果按照周统计 ,需要对某个月的周次信息进行计算,如果本月头一天不是星期一,则向上一个月取周一,本月最后的几天如果不能正好是一周,则忽略. 例如 2019-09月计算出来的结果 2016 ...
- PAT 1026. Table Tennis
A table tennis club has N tables available to the public. The tables are numbered from 1 to N. For ...
- tcpdump来抓取执行的sql语句
# tcpdump -n -nn -tttt -i eth1 -s 65535 'port 3306' -w tcpdump_mysql.ret -C 100 一个TCP包中包含多个mysql协议包, ...
- View,viewgroup,viewstub总结
:first-child { margin-top: 0; } blockquote > :last-child { margin-bottom: 0; } img { border: 0; m ...
- [置顶] sql 向另一个表导数据
1.如果目的表已经存在: 这两个表结构必须一致 insert into table1 select * from tabel2 2.如果目的表不存在: 这个类似与克隆表 select * into t ...
- FAQs: 我们可以在那里来为我的没有提升管理权限的应用程序存储用户数据?
如果你正在写一个不需要管理员权限的应用程序,如写一个业务线应用(Line of Business,LOB),用户应用程序如游戏,你总是要把应用程序的数据写到一个标准用可以访问的目录.下面列出一些所推荐 ...
- 自己做的demo--左连接
下面四张表是数据库中已经有的数据: 第一步: 1.left join左连接,left outer join 左外连接,只是写法不同,相同的概念. 2.左连接查出来的结果是一定包含left关键字左边的表 ...
- Error parsing XML: not well-formed (invalid token)
从网络上或别的文件复制粘贴进来的代码有隐含格式,可将内容先粘贴进记事本清除格式,再复制粘贴进工程文件,即可解决此问题 注:1. 要使工程文件全选清空, 2. 若粘贴后刷新仍无效果,可手动输入
- SQL Prompt Snippet Manager 妙用
SQL Prompt有一个很好用的工具叫Snippet Manager,SQL脚本片段管理器. 使用它可以快速的键入一段脚本,如输入ii+Tab,即可变成INSERT INTO 同理,我们可以定义一些 ...
- 本地tomcat的start.bat启动时访问不出现小猫图标
排除端口错误.看看是不是webapps的root文件夹删除了,如果删除了,从tomcat的压缩包中解压一个root文件夹,房里面即可