没有合适的资源?快使用搜索试试~ 我知道了~
首页Programming in Python 3, 2nd Edition
Programming in Python 3, 2nd Edition

Book Description It is more powerful, convenient, consistent, and expressive than ever before. Now, leading Python programmer Mark Summerfield demonstrates how to write code that takes full advantage of Python 3's features and idioms. Programming in Python 3, Second Edition, brings together all the knowledge you need to write any program, use any standard or third-party Python 3 library, and create new library modules of your own. Summerfield draws on his many years of Python experience to share deep insights into Python 3 development you won't find anywhere else.
资源详情
资源评论
资源推荐

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 the publisher was aware of a
trademark claim, the designations have been printed with initial capital letters or in all capitals.
The author and publisher have taken care in the preparation of this book, but make no expressed or
implied warranty of any kind and assume no responsibility for errors or omissions. No liability is
assumed for incidental or consequential damages in connection with or arising out of the use of the
information or programs contained herein.
The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases
or special sales, which may include electronic versions and/or custom covers and content particular
to your business, training goals, marketing focus, and branding interests. For more information,
please contact:
U.S. Corporate and Government Sales
(800) 382-3419
corpsales@pearsontechgroup.com
For sales outside the United States, please contact:
International Sales
international@pearsoned.com
Visit us on the Web: informit.com/aw
Library of Congress Cataloging-in-Publication Data
Summerfield, Mark.
Programming in Python 3 : a complete introduction to the Python language / Mark
Summerfield.—2nd ed.
p. cm.
Includes bibliographical references and index.
ISBN 978-0-321-68056-3 (pbk. : alk. paper)
1. Python (Computer program language) 2. Object-oriented programming (Computer science)
I. Title.
QA76.73.P98S86 2010
005.13
’
3—dc22
2009035430
Copyright
©
2010 Pearson Education, Inc.
All rights reserved. Printed in the United States of America. This publication is protected by
copyright, and permission must be obtained from the publisher prior to any prohibited reproduction,
storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical,
photocopying, recording, or likewise. For information regarding permissions, write to:
Pearson Education, Inc.
Rights and Contracts Department
501 Boylston Street, Suite 900
Boston, MA 02116
Fax: (617) 671-3447
ISBN-13: 978-0-321-68056-3
ISBN-10: 0-321-68056-1
Text printed in the United States on recycled paper at RR Donnelley in Crawfordsville, Indiana.
First printing, November 2009
www.it-ebooks.info

Contents at a Glance
List of Tables
...................................................... xv
Introduction
...................................................... 1
Chapter 1. Rapid Introduction to Procedural Programming
... 9
Chapter 2. Data Types
............................................ 51
Chapter 3. Collection Data Types
................................ 107
Chapter 4. Control Structures and Functions
................... 159
Chapter 5. Modules
...............................................195
Chapter 6. Object-Oriented Programming
...................... 233
Chapter 7. File Handling
......................................... 287
Chapter 8. Advanced Programming Techniques
................ 339
Chapter 9. Debugging, Testing, and Profiling
................... 413
Chapter 10. Processes and Threading
........................... 439
Chapter 11. Networking
..........................................457
Chapter 12. Database Programming
............................. 475
Chapter 13. Regular Expressions
................................ 489
Chapter 14. Introduction to Parsing
............................. 513
Chapter 15. Introduction to GUI Programming
................. 569
Epilogue
...........................................................595
Selected Bibliography
............................................ 597
Index
.............................................................. 599
www.it-ebooks.info

Contents
List of Tables
..................................................... xv
Introduction
...................................................... 1
Chapter 1
.
Rapid Introduction to Procedural Programming
... 9
Creating and Running Python Programs ........................ 9
Python’s “Beautiful Heart” ...................................... 14
Piece #1: Data Types ....................................... 14
Piece #2: Object References ................................. 16
Piece #3: Collection Data Types ............................. 18
Piece #4: Logical Operations ................................ 21
Piece #5: Control Flow Statements .......................... 26
Piece #6: Arithmetic Operators .............................. 30
Piece #7: Input/Output ..................................... 33
Piece #8: Creating and Calling Functions .................... 36
Examples ...................................................... 39
bigdigits.py ................................................ 39
generate_grid.py ........................................... 42
Summary ...................................................... 44
Exercises ...................................................... 47
Chapter 2
.
Data Types
........................................... 51
Identifiers and Keywords ....................................... 51
Integral Types .................................................. 54
Integers ................................................... 54
Booleans ................................................... 58
Floating-Point Types ........................................... 58
Floating-Point Numbers .................................... 59
Complex Numbers ......................................... 62
Decimal Numbers .......................................... 63
Strings ......................................................... 65
Comparing Strings ......................................... 68
Slicing and Striding Strings ................................ 69
String Operators and Methods .............................. 71
ix
www.it-ebooks.info

String Formatting with the str.format() Method .............. 78
Character Encodings ....................................... 91
Examples ...................................................... 94
quadratic.py ............................................... 94
csv2html.py ................................................ 97
Summary ...................................................... 102
Exercises ...................................................... 104
Chapter 3
.
Collection Data Types
................................ 107
Sequence Types ................................................ 107
Tuples ..................................................... 108
Named Tuples ............................................. 111
Lists ....................................................... 113
Set Types ...................................................... 120
Sets ....................................................... 121
Frozen Sets ................................................ 125
Mapping Types ................................................. 126
Dictionaries ................................................ 126
Default Dictionaries ........................................ 135
Ordered Dictionaries ....................................... 136
Iterating and Copying Collections ............................... 138
Iterators and Iterable Operations and Functions ............. 138
Copying Collections ........................................ 146
Examples ...................................................... 148
generate_usernames.py .................................... 149
statistics.py ................................................ 152
Summary ...................................................... 156
Exercises ...................................................... 158
Chapter 4
.
Control Structures and Functions
................... 159
Control Structures .............................................. 159
Conditional Branching ..................................... 159
Looping .................................................... 161
Exception Handling ............................................ 163
Catching and Raising Exceptions ........................... 163
Custom Exceptions ......................................... 168
Custom Functions .............................................. 171
Names and Docstrings ...................................... 176
Argument and Parameter Unpacking ....................... 177
x
www.it-ebooks.info
剩余635页未读,继续阅读














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

评论3