没有合适的资源?快使用搜索试试~ 我知道了~
首页快速入门:Python3最佳实战指南
快速入门:Python3最佳实战指南
需积分: 9 2 下载量 129 浏览量
更新于2024-07-25
收藏 2.89MB PDF 举报
"《快速Python》(The Quick Python Book, Second Edition)是一本备受推荐的Python入门书籍,由Vernon L. Ceder撰写,第二版特别针对Python 3进行了覆盖。这本书是基于Daryl K. Harms和Kenneth M. McDonald的第一版修订而成,旨在为初学者提供高效且易于理解的Python学习体验。它以简洁明快的方式介绍了Python语言的基础知识和核心概念,包括语法、数据类型、控制结构、函数、模块和面向对象编程等。 该书的特点在于其实用性和实用性,适合那些希望通过快速掌握这门流行编程语言来提升技能的人群。无论是希望进入IT行业的新人,还是希望在现有项目中引入Python的开发者,都能从中受益匪浅。Manning出版社出版的此书不仅提供纸质版本,还鼓励读者访问官网manning.com获取更多在线资源和订购信息,同时提供了批量购买的优惠。 版权方面,本书享有Manning Publications Co.的版权保护,任何未经许可的复制、存储或传输行为都必须获得书面授权。书中提到的一些制造商和销售商的产品名称可能被标记为商标,这是行业惯例,以示区分。 对于想要系统学习Python或者提升Python编程能力的读者来说,《快速Python》是一本不可多得的参考资料,它的详细指导和清晰讲解将帮助你在Python的世界里迅速上手并逐步深入。"
资源详情
资源推荐
CONTENTS
xv
20.3 Giving an object full list capability 252
20.4 Subclassing from built-in types 254
Subclassing list 254
■
Subclassing UserList 255
20.5 When to use special method attributes 256
20.6 Metaclasses 256
20.7 Abstract base classes 258
Using abstract base classes for type checking 259
■
Creating
abstract base classes 260
■
Using the @abstractmethod and
@abstractproperty decorators 260
20.8 Summary 262
PART 4WHERE CAN YOU GO FROM HERE? ................. 263
21
Testing your code made easy(-er) 265
21.1 Why you need to have tests 265
21.2 The assert statement 266
Python’s __debug__ variable 266
21.3 Tests in docstrings: doctests 267
Avoiding doctest traps 269
■
Tweaking doctests with
directives 269
■
Pros and cons of doctests 270
21.4 Using unit tests to test everything, every time 270
Setting up and running a single test case 270
■
Running the
test 272
■
Running multiple tests 272
■
Unit tests vs.
doctests 273
21.5 Summary 273
22
Moving from Python 2 to Python 3 274
22.1 Porting from 2 to 3 274
Steps in porting from Python 2.x to 3.x 275
22.2 Testing with Python 2.6 and -3 276
22.3 Using 2to3 to convert the code 277
22.4 Testing and common problems 279
22.5 Using the same code for 2 and 3 280
Using Python 2.5 or earlier 280
■
Writing for Python 3.x and
converting back 281
22.6 Summary 281
Licensed to Kerri Ross <pedbro@gmail.com>
CONTENTS
xvi
23
Using Python libraries 282
23.1 “Batteries included”—the standard library 282
Managing various data types 283
■
Manipulating files and
storage 284
■
Accessing operating system services 285
■
Using
internet protocols and formats 286
■
Development and debugging
tools and runtime services 286
23.2 Moving beyond the standard library 287
23.3 Adding more Python libraries 287
23.4 Installing Python libraries using setup.py 288
Installing under the home scheme 288
■
Other installation
options 289
23.5 PyPI, a.k.a. “the Cheese Shop” 289
23.6 Summary 289
24
Network, web, and database programming 290
24.1 Accessing databases in Python 291
Using the sqlite3 database 291
24.2 Network programming in Python 293
Creating an instant HTTP server 293
■
Writing an HTTP
client 294
24.3 Creating a Python web application 295
Using the web server gateway interface 295
■
Using the wsgi
library to create a basic web app 295
■
Using frameworks to create
advanced web apps 296
24.4 Sample project—creating a message wall 297
Creating the database 297
■
Creating an application
object 298
■
Adding a form and retrieving its contents
298
■
Saving the form’s contents 299
■
Parsing the URL and
retrieving messages 300
■
Adding an HTML wrapper 303
24.5 Summary 304
appendix 305
index 323
Licensed to Kerri Ross <pedbro@gmail.com>
xvii
preface
I’ve been coding in Python for a number of years, longer than any other language I’ve
ever used. I use Python for system administration, for web applications, for database
management, and sometimes just to help myself think clearly.
To be honest, I’m sometimes a little surprised that Python has worn so well. Based
on my earlier experience, I would have expected that by now some other language
would have come along that was faster, cooler, sexier, whatever. Indeed, other lan-
guages have come along, but none that helped me do what I needed to do quite as
effectively as Python. In fact, the more I use Python and the more I understand it, the
more I feel the quality of my programming improve and mature.
This is a second edition, and my mantra in updating has been, “If it ain’t broke,
don’t fix it.” Much of the content has been freshened for Python 3 but is largely as
written in the first edition. Of course, the world of Python has changed since Python
1.5, so in several places I’ve had to make significant changes or add new material. On
those occasions I’ve done my best to make the new material compatible with the clear
and low-key style of the original.
For me, the aim of this book is to share the positive experiences I’ve gotten from
coding in Python by introducing people to Python 3, the latest and, in my opinion,
the best version of Python to date. May your journey be as satisfying as mine has been.
Licensed to Kerri Ross <pedbro@gmail.com>
xviii
acknowledgments
I want to thank David Fugate of LaunchBooks for getting me into this book in the first
place and for all of the support and advice he has provided over the years. I can’t
imagine having a better agent and friend. I also need to thank Michael Stephens of
Manning for pushing the idea of doing a second edition of this book and supporting
me in my efforts to make it as good as the first. Also at Manning, many thanks to every
person who worked on this project, with special thanks to Marjan Bace for his support,
Tara Walsh for guidance in the development phases, Mary Piergies for getting the
book (and me) through the production process, Linda Recktenwald for her patience
in copy editing, and Tiffany Taylor for proofreading. I also owe a huge debt to Will
Kahn-Greene for all of the astute advice he gave both as a technical reviewer and in
doing the technical proofing. Thanks, Will, you saved me from myself more times
than I can count. Likewise, hearty thanks to the many reviewers whose insights and
feedback were of immense help: Nick Lo, Michele Galli, Andy Dingley, Mohamed
Lamkadem, Robby O'Connor, Amos Bannister, Joshua Miller, Christian Marquardt,
Andrew Rhine, Anthony Briggs, Carlton Gibson, Craig Smith, Daniel McKinnon,
David McWhirter, Edmon Begoli, Elliot Winard, Horaci Macias, Massimo Perga,
Munch Paulson, Nathan R. Yergler, Rick Wagner, Sumit Pal, and Tyson S. Maxwell.
Because this is a second edition, I have to thank the authors of the first edition,
Daryl Harms and Kenneth MacDonald, for two things: first, for writing a book so sound
that it has remained in print well beyond the average lifespan of most tech books, and
second, for being otherwise occupied, thereby giving me a chance to update it. I hope
this version carries on the successful and long-lived tradition of the first.
Licensed to Kerri Ross <pedbro@gmail.com>
ACKNOWLEDGMENTS
xix
Thanks to my canine associates, Molly, Riker, and Aeryn, who got fewer walks,
training sessions, and games of ball than they should have but still curled up beside
my chair and kept me company and helped me keep my sense of perspective as I
worked. You’ll get those walks now, guys, I promise.
Most important, thanks to my wife, Becky, who both encouraged me to take on this
project and had to put up with the most in the course of its completion—particularly
an often-grumpy and preoccupied spouse. I really couldn’t have done it without you.
Licensed to Kerri Ross <pedbro@gmail.com>
剩余361页未读,继续阅读
zhangxu84
- 粉丝: 1
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- AirKiss技术详解:无线传递信息与智能家居连接
- Hibernate主键生成策略详解
- 操作系统实验:位示图法管理磁盘空闲空间
- JSON详解:数据交换的主流格式
- Win7安装Ubuntu双系统详细指南
- FPGA内部结构与工作原理探索
- 信用评分模型解析:WOE、IV与ROC
- 使用LVS+Keepalived构建高可用负载均衡集群
- 微信小程序驱动餐饮与服装业创新转型:便捷管理与低成本优势
- 机器学习入门指南:从基础到进阶
- 解决Win7 IIS配置错误500.22与0x80070032
- SQL-DFS:优化HDFS小文件存储的解决方案
- Hadoop、Hbase、Spark环境部署与主机配置详解
- Kisso:加密会话Cookie实现的单点登录SSO
- OpenCV读取与拼接多幅图像教程
- QT实战:轻松生成与解析JSON数据
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功