1、dict函数
>>> items = [('name','Gumby'),('age',42)] >>> d = dict(items) >>> d {'age': 42, 'name': 'Gumby'} >>> d = dict(name='Gumby',age=42) >>> d {'age': 42, 'name': 'Gumby'}
2、fromkeys
>>> {}.fromkeys(['name','age']) {'age': None, 'name': None} >>> dict.fromkeys(['name','age']) {'age': None, 'name': None} >>> dict.fromkeys(['name','age'],'(unknow)') {'age': '(unknow)', 'name': '(unknow)'}
3、get
>>> d={} >>> print d.get('name') None >>> print d.get('name','default') default
4、各种方法
has_key
items列表 iteritems迭代器
keys iterkeys 同上
values itervalues
pop('....key...') popitem弹出随机项
setdefault 设置key的default值
update 用另一个字典添加并覆盖
相关推荐
Chapter 13: Writing a GUI with Python 209 GUI Programming Toolkits for Python 209 PyGTK Introduction 210 pyGTK Resources 211 Creating GUI Widgets with pyGTK 213 Try It Out: Writing a Simple pyGTK...
Beginning Python from Novice to Professional Beginning Python from Novice to Professional
Beginning Python Games Development, Second Edition
《 Beginning Python:Using Python 2.6 and Python 3.1》是一本旨在引导初学者入门Python编程语言的书籍,特别关注Python 2.6和3.1这两个版本。这本书涵盖了从基本语法到高级概念的广泛主题,为读者提供了一个全面...
Beginning Python Games Development, 2nd Edition will teach you how to create visuals, do event handling, create 3D games, add media elements, and integrate OpenGL into your Python game. In this ...
Updated to reflect the latest in Python programming paradigms and several of the most crucial features found in Python 3, Beginning Python also covers advanced topics such as extending Python and ...
Beginning Python From Novice to Professional(3rd) 英文epub 第3版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
Chapter 4: Making Decisions 51 Chapter 5: Functions 71 Chapter 6: Classes and Objects 93 Chapter 7: Organizing Programs 111 Chapter 8: Files and Directories 127 Chapter 9: Other Features of the ...
Python基础教程 Beginning Python From Novice to Professional.zip,收录了 Python基础教程 Beginning Python From Novice to Professional 中英文各版本和源码,包括(第2版)和 (第3版),都有详尽的书签,不是一级...
Beginning python 3.pdf
Beginning Python Visualization(2nd) 英文无水印pdf 第2版 pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权...
2015年第二版,Beginning Game Development with Python and Pygame 的新版,Beginning Python Games Development, Second Edition 作者: Will McGugan 出版社: Apress 副标题: With PyGame 出版年: 2015-6-21 ...
“开始Python:使用Python 2.6和Python 3.1引入了这种开源的、可移植的、解释的、面向对象的编程语言,它结合了强大的功能和清晰的语法。本书通过讲授基础知识,使您能够快速创建健壮、可靠和可重用的Python应用程序...
Beginning Python - From Novice To Professional英文原版PDF,可复制,适合入门python
Beginning Python From Novice to Professional(3rd) 英文无水印pdf 第3版 pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自...
"Beginning Python:Using Python 2.6 and Python 3.1-628页" 本书籍《Beginning Python:Using Python 2.6 and Python 3.1》是Python语言的入门书籍,对于初学者和中级开发者都非常适用。该书籍涵盖了Python语言的...
- 变量与数据类型:Python支持整型、浮点型、字符串、布尔型等多种数据类型,以及列表、元组、字典和集合等复合数据结构。 - 控制流:包括条件语句(if-else)、循环语句(for、while)以及异常处理(try-except)...
在Python语法方面,本书详细介绍了Python的基础语法元素,包括变量、数据类型(如整型、浮点型、字符串、列表、元组、字典等)、控制结构(如if语句、for循环、while循环)、函数定义与调用、类与对象等面向对象编程...
Beginning Python From Novice to Professional 3rd Edition by Magnus Lie Hetland
Python 经典英文原版教材,可视化编程教程,适合有一定python编程基础的开发人员使用