没有合适的资源?快使用搜索试试~ 我知道了~
首页Programming Python 4th 原版PDF by Lutz
Programming Python 4th 原版PDF by Lutz
需积分: 10 94 浏览量
更新于2023-03-16
评论
收藏 17.06MB PDF 举报
This book explores ways to apply the Python programming language in common application domains and realistically scaled tasks. It’s about what you can do with the language once you’ve mastered its fundamentals. This book assumes you are relatively new to each of the application domains it covers— GUIs, the Internet, databases, systems programming, and so on—and presents each from the ground up, in tutorial fashion. Along the way, it focuses on commonly used tools and libraries, rather than language fundamentals. The net result is a resource that provides readers with an in-depth understanding of Python’s roles in practical, realworld programming work.
资源详情
资源评论
资源推荐


FOURTH EDITION
Programming Python
Mark Lutz
Beijing
•
Cambridge
•
Farnham
•
Köln
•
Sebastopol
•
Tokyo

Programming Python, Fourth Edition
by Mark Lutz
Copyright © 2011 Mark Lutz. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly
books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (http://my.safaribooksonline.com). For more information, contact our
corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com.
Editor: Julie Steele
Production Editor: Teresa Elsey
Proofreader: Teresa Elsey
Indexer: Lucie Haskins
Cover Designer: Karen Montgomery
Interior Designer: David Futato
Illustrator: Robert Romano
Printing History:
October 1996:
First Edition.
March 2001: Second Edition.
August 2006: Third Edition.
December 2010: Fourth Edition.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly
Media, Inc. Programming Python, the image of an African rock python, and related trade dress
are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume
no responsibility for errors or omissions, or for damages resulting from the use of the information con-
tained herein.
ISBN: 978-0-596-15810-1
[QG]
1292258056

Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
Part I. The Beginning
1. A Sneak Preview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
“Programming Python: The Short Story” 3
The Task 4
Step 1: Representing Records 4
Using Lists 4
Using Dictionaries 9
Step 2: Storing Records Persistently 14
Using Formatted Files 14
Using Pickle Files 19
Using Per-Record Pickle Files 22
Using Shelves 23
Step 3: Stepping Up to OOP 26
Using Classes 27
Adding Behavior 29
Adding Inheritance 29
Refactoring Code 31
Adding Persistence 34
Other Database Options 36
Step 4: Adding Console Interaction 37
A Console Shelve Interface 37
Step 5: Adding a GUI 40
GUI Basics 40
Using OOP for GUIs 42
Getting Input from a User 44
A GUI Shelve Interface 46
Step 6: Adding a Web Interface 52
CGI Basics 52
v
Download from Wow! eBook <www.wowebook.com>

Running a Web Server 55
Using Query Strings and urllib 57
Formatting Reply Text 59
A Web-Based Shelve Interface 60
The End of the Demo 69
Part II. System Programming
2. System Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
“The os.path to Knowledge” 73
Why Python Here? 73
The Next Five Chapters 74
System Scripting Overview 75
Python System Modules 76
Module Documentation Sources 77
Paging Documentation Strings 78
A Custom Paging Script 79
String Method Basics 80
Other String Concepts in Python 3.X: Unicode and bytes 82
File Operation Basics 83
Using Programs in Two Ways 84
Python Library Manuals 85
Commercially Published References 86
Introducing the sys Module 86
Platforms and Versions 86
The Module Search Path 87
The Loaded Modules Table 88
Exception Details 89
Other sys Module Exports 90
Introducing the os Module 90
Tools in the os Module 90
Administrative Tools 91
Portability Constants 92
Common os.path Tools 92
Running Shell Commands from Scripts 94
Other os Module Exports 100
3. Script Execution Context .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
“I’d Like to Have an Argument, Please” 103
Current Working Directory 104
CWD, Files, and Import Paths 104
CWD and Command Lines 106
vi | Table of Contents
剩余1622页未读,继续阅读
















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0