logo资料库

Python Pocket Reference 5th 原版PDF by Lutz.pdf

第1页 / 共264页
第2页 / 共264页
第3页 / 共264页
第4页 / 共264页
第5页 / 共264页
第6页 / 共264页
第7页 / 共264页
第8页 / 共264页
资料共264页,剩余部分请下载后查看
Table of Contents
Introduction
Book Conventions
Python Command-Line Usage
Python Command Options
Command-Line Program Specification
Python 2.X Command Options
Python Environment Variables
Operational Variables
Python Command Option Variables
Python Windows Launcher Usage
Launcher File Directives
Launcher Command Lines
Launcher Environment Variables
Built-in Types and Operators
Operators and Precedence
Operator Usage Notes
Operations by Category
Sequence Operation Notes
Specific Built-in Types
Numbers
Strings
Unicode Strings
Lists
Dictionaries
Tuples
Files
Sets
Other Types and Conversions
Statements and Syntax
Syntax Rules
Name Rules
Specific Statements
The Assignment Statement
The Expression Statement
The print Statement
The if Statement
The while Statement
The for Statement
The pass Statement
The break Statement
The continue Statement
The del Statement
The def Statement
The return Statement
The yield Statement
The global Statement
The nonlocal Statement
The import Statement
The from Statement
The class Statement
The try Statement
The raise Statement
The assert Statement
The with Statement
Python 2.X Statements
Namespace and Scope Rules
Qualified Names: Object Namespaces
Unqualified Names: Lexical Scopes
Nested Scopes and Closures
Object-Oriented Programming
Classes and Instances
Pseudoprivate Attributes
New-Style Classes
Formal Inheritance Rules
Operator Overloading Methods
Methods for All Types
Methods for Collections (Sequences, Mappings)
Methods for Numbers (Binary Operators)
Methods for Numbers (Other Operations)
Methods for Descriptors
Methods for Context Managers
Python 2.X Operator Overloading Methods
Built-in Functions
Python 2.X Built-in Functions
Built-in Exceptions
Superclasses: Categories
Specific Exceptions
Specific OSError Exceptions
Warning Category Exceptions
Warnings Framework
Python 3.2 Built-in Exceptions
Python 2.X Built-in Exceptions
Built-in Attributes
Standard Library Modules
The sys Module
The string Module
Functions and Classes
Constants
The os System Module
Administrative Tools
Portability Constants
Shell Commands
Environment Tools
File Descriptor Tools
File Pathname Tools
Process Control
The os.path Module
The re Pattern-Matching Module
Module Functions
Regular Expression Objects
Match Objects
Pattern Syntax
Object Persistence Modules
The shelve and dbm Modules
The pickle Module
The tkinter GUI Module and Tools
tkinter Example
tkinter Core Widgets
Common Dialog Calls
Additional tkinter Classes and Tools
Tcl/Tk-to-Python/tkinter Mappings
Internet Modules and Tools
Other Standard Library Modules
The math Module
The time Module
The timeit Module
The datetime Module
The random Module
The json Module
The subprocess Module
The enum Module
The struct Module
Threading Modules
Python SQL Database API
API Usage Example
Module Interface
Connection Objects
Cursor Objects
Type Objects and Constructors
More Hints and Idioms
Core Language Hints
Environment Hints
Usage Hints
Assorted Hints
Index
FIFTH EDITION Python Pocket Reference Mark Lutz
Python Pocket Reference, Fifth Edition by Mark Lutz Copyright © 2014 Mark Lutz. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebasto‐ pol, 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.safaribookson line.com). For more information, contact our corporate/institutional sales de‐ partment: 800-998-9938 or corporate@oreilly.com. Editor: Rachel Roumeliotis Production Editor: Kristen Brown Copyeditor: Richard Carey Proofreader: Amanda Kersey Indexer: Lucie Haskins Cover Designer: Randy Comer Interior Designer: David Futato October 1998: January 2002: February 2005: October 2009: February 2014: Revision History for the Fifth Edition: First Edition Second Edition Third Edition Fourth Edition Fifth Edition 2014-01-17: First release See http://oreilly.com/catalog/errata.csp?isbn=9781449357016 for release de‐ tails. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Python Pocket Reference, the im‐ age of a 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 authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. ISBN: 978-1-449-35701-6 [M]
Table of Contents Introduction Book Conventions Python Command-Line Usage Python Command Options Command-Line Program Specification Python 2.X Command Options Python Environment Variables Operational Variables Python Command Option Variables Python Windows Launcher Usage Launcher File Directives Launcher Command Lines Launcher Environment Variables Built-in Types and Operators Operators and Precedence Operator Usage Notes Operations by Category Sequence Operation Notes Specific Built-in Types Numbers 1 2 3 4 5 7 7 8 9 10 10 11 11 12 12 14 16 20 21 22 iii
Strings Unicode Strings Lists Dictionaries Tuples Files Sets Other Types and Conversions Statements and Syntax Syntax Rules Name Rules Specific Statements The Assignment Statement The Expression Statement The print Statement The if Statement The while Statement The for Statement The pass Statement The break Statement The continue Statement The del Statement The def Statement The return Statement The yield Statement The global Statement The nonlocal Statement The import Statement The from Statement The class Statement The try Statement The raise Statement iv | Table of Contents 24 42 46 53 57 58 63 65 67 67 69 71 72 76 77 80 80 80 81 81 81 81 82 86 87 88 89 89 93 95 97 99
The assert Statement The with Statement Python 2.X Statements Namespace and Scope Rules Qualified Names: Object Namespaces Unqualified Names: Lexical Scopes Nested Scopes and Closures Object-Oriented Programming Classes and Instances Pseudoprivate Attributes New-Style Classes Formal Inheritance Rules Operator Overloading Methods Methods for All Types Methods for Collections (Sequences, Mappings) Methods for Numbers (Binary Operators) Methods for Numbers (Other Operations) Methods for Descriptors Methods for Context Managers Python 2.X Operator Overloading Methods Built-in Functions Python 2.X Built-in Functions Built-in Exceptions Superclasses: Categories Specific Exceptions Specific OSError Exceptions Warning Category Exceptions Warnings Framework Python 3.2 Built-in Exceptions Python 2.X Built-in Exceptions Built-in Attributes Standard Library Modules 101 102 104 105 105 105 107 108 109 110 111 112 117 118 123 125 128 129 130 131 134 155 161 162 163 167 169 170 171 172 172 173 Table of Contents | v
The sys Module The string Module Functions and Classes Constants The os System Module Administrative Tools Portability Constants Shell Commands Environment Tools File Descriptor Tools File Pathname Tools Process Control The os.path Module The re Pattern-Matching Module Module Functions Regular Expression Objects Match Objects Pattern Syntax Object Persistence Modules The shelve and dbm Modules The pickle Module The tkinter GUI Module and Tools tkinter Example tkinter Core Widgets Common Dialog Calls Additional tkinter Classes and Tools Tcl/Tk-to-Python/tkinter Mappings Internet Modules and Tools Other Standard Library Modules The math Module The time Module The timeit Module vi | Table of Contents 174 182 182 183 184 185 186 187 189 190 193 197 200 202 202 205 205 207 210 211 213 216 216 217 218 219 220 221 224 224 225 226
The datetime Module The random Module The json Module The subprocess Module The enum Module The struct Module Threading Modules Python SQL Database API API Usage Example Module Interface Connection Objects Cursor Objects Type Objects and Constructors More Hints and Idioms Core Language Hints Environment Hints Usage Hints Assorted Hints Index 227 228 228 229 229 230 231 232 233 234 234 235 236 236 237 238 240 242 243 Table of Contents | vii
分享到:
收藏