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:Using Python 2.6 and Python 3.1》
Beginning Python from Novice to Professional Beginning Python from Novice to Professional
Beginning Python Games Development, Second Edition
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 ...
beginning python from novice to professional 源代码,python 基础教程
Python基础教程 Beginning Python From Novice to Professional.zip,收录了 Python基础教程 Beginning Python From Novice to Professional 中英文各版本和源码,包括(第2版)和 (第3版),都有详尽的书签,不是一级...
Beginning python 3.pdf
Beginning Python From Novice to Professional(3rd) Beginning Python From Novice to Professional(3rd)
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删除 本资源转载自...
python基础教程 (Beginning Python From Novice to Professional) 书中源码例子
Beginning Python From Novice to Professional 3rd Edition by Magnus Lie Hetland
Python 经典英文原版教材,可视化编程教程,适合有一定python编程基础的开发人员使用