4.python字典和None类型
2012-03-30 17:22
246 查看
例一:
#-*-coding:UTF-8-*- a_dict={'chen':1,'jian':2} #创建一个字典 a_dict['chen'] #通过key来访问 a_dict['chen']=3 #修改字典 print a_dict a_dict['jian']=[4,5,6,7] print a_dict print 'chen' in a_dict # #None是python中一个特殊常量,是一个空值。与任何东西进行比较将总是返回false #
例二:
#-*-coding:UTF-8-*- dict2={'a':1,'b':2} for d2 in dict2.keys(): #使用keys()方法来遍历字典是一种很常用的方法 print d2 dict1={'c':3,'d':4} dict1.update(dict2) #常用来将两个字典进行连接 print dict1 dict1.clear() #清空字典
相关文章推荐
- 4.python字典和None类型
- python内置映射类型(mapping type):dict哈希字典遍历方式及其它用法举例
- 详解Python中映射类型(字典)操作符的概念和使用
- Python 字典类型及相关操作
- Python变量类型(l整型,长整形,浮点型,复数,列表,元组,字典)学习
- Python中让MySQL查询结果返回字典类型的方法
- 复习1次课(11月28日) 1.3 python的文件类型 1.4 python的变量 1.5 python的数值和字符串 1.6 元组 1.7 列表 1.8 字典 1.9 字典练习
- 让python的mysqldb返回的结果集为字典类型
- 07-python_数据类型-字典
- python之元组字典及set类型
- SAE Python urllib2因请求头字典键名为Unicode类型引发的异常问题
- python如何将字符串转换成字典dict类型
- python判断对象的类型(字典,列表,集合等)
- python数据类型—列表、元组、字典
- python基础入门详解(文件输入/输出 内建类型 字典操作使用方法)
- python学习笔记2—python文件类型、变量、数值、字符串、元组、列表、字典
- Python核心数据类型——列表与字典
- Python数据类型详解(四)字典:dict
- Python 字典类型及相关操作
- Python数据类型(元组、列表、字符串、字典)