作者:empty 页数:1594 出版社:empty |
Get a comprehensive, in-depth introduction to the core Pythonlanguage with this hands-on book.Based on author Mark Lutz'spopular training course, this updated fifth edition will help youquickly write efficient, high-quality code with Python.lt'sanideal way to begin, whether you renew to programming or aprofessional developer versed in other languages.Comple re with quizzes, exercises, and helpful i lust rations, thiseasy-to-follow, self-paced tutorial gets you started with bothPython 2.7 and 3.3—the latest releases in the 3X and 2.X lines-plus all other releases in common use today.Youll also learnsome advanced language features that recently have become morecommon in Python code.
M Explore Python'major built-in object types such asCreate and process objects with Python statements, andmUse functions to avoid code redundancy and package codem Organize statements, functions, and other tools into largerwDiveintoclasses:Python'sobject-orientedprogrammingw Wrte large programs with Python's exception-handlingm Learn advanced Python tools, including decorators,
Module Imports and Reloads
Import and Reload Basics
Sequence Operations
Immutability
Type Specific Methods
Getting Help
Other Ways to CodeS tn ngs
Unicode Strings
Pat tem Matching
Sequence Operations
Type-speci tic Operations
Bounds Checking
Nesting
Compr chen sions
Mapping Operations
Nesting Revisited
Missing Keys:if Tests
Sorting Keys:for Loops
Iteration and Optimization
Why Tuples?
Binary Bytes Files
Unicode Text Files
Other File Like Tools
Numeric Literals
Built-in Numeric Tools
Python Expression Operators
Van ables and Basic Expressions
Numer c DispLay Formats
Comparisons:Normal and Chained
Division:Classic, Floor, and True
Integer Precision
Complex Numbers
The Grander Module Story:Attr but es
Usage Notes:import and reload
Using exec to Run Module Files
The IDLE UserInterface
IDLE Startup Details
IDLE Basic Usage
IDLE Usability Features
Advanced IDLE Tools
Usage Notes:IDLE
Other IDEs
Other Launch Options
Embedding Calls
Frozen Binary Executables
TextEditor Launch Options
Stil Other Launch Options
Future Possibilities?
Which Option Should I Use?
Chapter Summary
Test Your Knowledge:Quiz
Test Your Knowledge:Answers
Test Your Knowledge:Part I Exercises
Types and Operations
4.Introducing Python Object Types.
The Python Conceptual Hierarchy
Why Use Built-in Types?
Python'sCore DataTypes
Strings
Lists
Dictionaries
Tuples
Files
Other Core Types
Part II.
Numbers
TableofContents|wi
Howto Break Your Code's Flexibility
User-Defined Classes
And Everything Else
Chapter Summary
Test Your Knowledge:Quiz
Test Your Knowledge:Answers
5.Numeric Types.
Num encType Basics
Numbers in Action
ui|Tab be of Content
Hex, Octal, Binary:Literals and Conversions
Bitwise Operations
Other Built-in Numen c Tools
Other Numeric Types
Decimal Type
Fraction Type
Sets
Booleans
Numeric Extensions
Chapter Summary
Test Your Knowledge:Quiz
Test Your Knowledge:Answers
6.The Dynamic Typing Interlude.
The Case of the Miss ng De car a on Statements
Variables, Objects, and References
Types Live with Objects, Nor Variables
Objects Are Garbage-Collected
Shared References
Shared References and In-Place Changes
Shared References and Equality
Dynamic Typing Is Everywhere
Chapter Summary
Test Your Knowledge:Quiz
Test Your Knowledge:Answers
7.String Fundamentals.
This Chapter's Scope
Unicode:The Short Story
String Basics
String Literals
Basic List Operations
Single-and Double-Quoted Strings Are the Same
Escape Sequences Represent Special Characters
Raw Strings Suppress Escapes
Triple Quotes Code Multi in e Block Strings
Strings in Action
Basic Operations
Indexing and Slicing
String Conversion Tools
Changing Strings I
String Methods
Method Call Syntax
Methods of Strings
String Method Examples:Changing Strings II
String Method Examples:Parsing Text
Other Common String Methods in Action
The Original string Module's Functions(Gone in 3.X)
String Formatting Expressions
Formatting Expression Basics
Advanced Formatting Expression Syntax
Advanced Formatting Expression Examples
Dictionary-Based Formatting Expressions
String Formatting Method Calls
Formatting Method Basics
Adding Keys.Attributes, and Offsets
Advanced Formatting Method Syntax
Advanced Formatting Method Examples
Comparison to the%Formatting Expression
Why the Format Method?
General Type Categories
Types Share Operation Sets by Categories
Mutable Types Can Be Changed in Place
Chapter Summary
Test Your Knowledge.Quiz
Test Your Knowledge:Answers
8.Lists and Dictionaries.
Lists
Lists in Action
9.Tuples, Files, and Everything Else.
x|TableofContents
TableofContents|x
List Iteration and Comprehensions
Indexing, S icing, and Matrixes
Changing Lists in Place
Dictionaries
Dictionaries in Action
Basic Dictionary Operations
Changing Dictionaries in Place
More Dictionary Methods
Example:Movie Database
Dictionary Usage Notes
Other Ways to Make Dictionaries
Dictionary Changes in Python 3X and 2.7
Chapter Summary
Test Your Knowledge:Quiz
Test Your Knowledge:Answers
Tuples
Tuples in Action
Why Lists and Tuples?
Records Re visa ted:Named Tuples
Files
Opening Files
Using Files
Files in Action
Text and Binary Files:The Short Story
Storing Python Objects in Files:Conversions
Storing Native Python Objects:pickle
Storing Python Objects in JSON Format
Storing Packed Binary Data:struct
File Context Managers
Other File Tools
Core Types Review and Summary
Object Flexibility
References Versus Copies
Comparisons, Equality, and Truth
The Meaning of True and False in Python
Python's Type Hierarchies
Type Objec is
Other Types in Python
Built-in Type Gotchas
Assign men r Creates References, Nor Copies
Repetition Adds One Level Deep
Beware of Cyclic DataStructures
Immutable Types Can't Be Changed in Place
Chapter Summary
Test Your Knowledge:Quiz
Test Your Knowledge:Answers
Test Your Knowledge:Part Il Exercises
Statements and Syntax
The Python Conceptual Hir archy Rev sited
Python's Statements
A Tale of Two ifs
Whar Python Adds
What Python Removes
Why Indentation Syntax?
A Few Special Cases
A Quick Example:Interac rivel.oops
A Simple Interactive L.oop
Doing Math on User Inputs
Handing Errors by Testing Inputs
Handling Errors with try Statements
Nesting Code Three Levels Deep
Test Your Knowledge:Quiz
Test Your Knowledge:Answers
Assignment Statements
Assignment Statement Forms
Sequence Assignments
Extended Sequence Unpacking in Python 3.X
Multiple-Target Assignments
Augmented Assignments
Van able Name Rules
Expression Statements
Expression Statements and In-Place Changes
Print Operations
The Python 3X print Function
The Python 2.Xprint Statement
PrintStream Redirection
Version-Neutral Printing
Test Your Knowledge:Quiz
Test Your Knowledge:Answers
General Format
Basic Examples
Multiway Branching
Python Syntax Revisited
Block Delimiters:Indentation Rules
Statement Delimiters:Lines and Continuations
A Few Special Cases
Truth Values and Boolean Tests
The if/else Ternary Expression
Test Your Knowledge:Quiz
Test Your Knowledge:Answer