文件名称:
Beginning python 3.pdf.pdf
开发工具:
文件大小: 6mb
下载次数: 0
上传时间: 2019-09-14
详细说明:Beginning python 3.pdfBeginning Python: From Novice to Professional
Magnus Lie hetland
Trondheim, Norway
ISBN13(pbk):978-1-48420029-2
SBN-l3( electronic):978-1-4842-0028-5
DOI10.1007/978-1-4842-0028-5
Library of congress Control Number: 2017934891
Copyright o 2017 by Magnus Lie Hetland
This work is subject to copyright All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage
and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or
hereafter developed
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are
notidentified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein
Managing Director: Welmoed Spahr
Lead Editor: Steve Anglin
Development Editor: Matthew Moodie
Technical reviewer: michael Thomas
Coordinating editor: Mark Powers
Copy Editor: Kim Wimpsett
Compositor: SPi Global
Indexer: SPi global
Artist: SPi globa
Cover image designed by shutterstock
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street,
6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax(201)348-4505, e-mail orders-nyspringer
sbmcomorvisitwww.springeronline.comApressmediaLlcisaCaliforniaLlcandthesolemember
(owner) is Springer Science Business Media Finance Inc(SSBM Finance Inc). SSBM Finance Inc is a
Delaware corporation
Forinformationontranslationspleasee-mailrightsapress.com,orvisitwww.apress.com/us/services/
rights-permission
Apress titles may be purchased in bulk for academic, corporate, or promotional use eBook versions
licenses are also available for most titles for more information reference our print and ebook bulk sales web
pageatwww.apress.com/bulk-sales
Any source code or other supplementary material referenced by the author in this book is available to readers
fordownloadorcloningatGithubviathebooksproductpagelocatedatwww.apress.com/9781484200292
Formoredetailedinformationpleasevisithttp://www.apress.com/us/services/source-code
Printed on acid-free paper
For Kiersti and Tor.
欢迎加入非盈利 Pyt hor学习交流编程Q群783462347,群里免费提供5004本 Pyt hoη书籍
Contents at a glance
About the author…nxv
About the technical reviewer
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
XXVI
Preface
Introduction
Chapter 1: Instant Hacking: The basics amaammmmmmmman 1
Chapter 2: Lists and Tuples amant
■■■■■口■■■■
■■■■■口■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■■■■■■■■■■■■■■■■■■
25
Chapter 3: Working with Strings
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
45
Chapter 4: Dictionaries: When Indices Won't Do aa
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
59
Chapter 5: Conditionals, Loops, and Some other Statements mmmmmmmm 71
Chapter 6: Abstraction.
101
Chapter 7: More Abstraction
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
129
Chapter 8: Exceptions.tamar
na149
Chapter 9: Magic Methods Properties, and iterators mmmmmm 163
Chapter 10: Batteries Included
u195
Chapter 11: Files and stuff
241
Chapter 12: Graphical User Interfaces
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
253
Chapter 13: Database Support.
Chapter 14: Network Programming amm m mmm Eman 273
Chapter 15: Python and the Web
a289
Chapter 16: Testing, 1-2-3mmHBBRBBBIB BEEBBEEB BEIBIRRIBMMEIIIIEIRIIIIIIRIREIIRI 307
欢迎加入非盈利 Pyt hor学习交流编程Q群783462347,群里免费提供5004本 Pyt hoη书籍
CONTENTS ATA GLANCE
Chapter 17: Extending Python
u321
Chapter 18: Packaging Your Programsmmmaa
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
337
Chapter 19: Playful Programming
n343
Chapter 20: Project 1: Instant Markup
353
Chapter21: Project 2: Painting a Pretty Picture.,,,,……,,,,,…373
Chapter 22: Project 3: XML for All Occasions aaIn 383
Chapter 23: Project 4: In the News. mmaa mmmmaan 397
Chapter 24: Project 5: A Virtual Tea Party
409
Chapter 25: Project 6: Remote Editing with CGI
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
425
Chapter 26: Project 7: Your Own Bulletin Board
435
Chapter 27: Project 8: File sharing with XML-RPCmmmmnmm, 451
Chapter 28: Project 9: File sharing ll-Now with gUi!aaat
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
467
Chapter 29: Project 10: Do-lt-Yourself Arcade Game aaa
475
Appendix A: The short Version
n495
Appendix B: python Reference
503
Indexummmmm 519
欢迎加入非盈利 Pyt hor学习交流编程Q群783462347,群里免费提供5004本 Pyt hoη书籍
Contents
About the author…nxv
About the technical reviewer
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
XXVI
Preface
Introduction
Chapter 1: Instant Hacking: The basics amaammmmmmmman 1
The Interactive Interpreter
Algo...What?…
Numbers and Expressions
Hexadecimal octals and binary .
Variables
23556
Statements…
Getting Input from the User
Functions
6789
Modules
cmath and Complex Numbers ..tem. 10
Back to the future
Saving and Executing Your Programs.
Running Your Python Scripts from a Command Prompt .
Making Your Scripts Behave Like Normal Programs....................... 13
Comments
14
Strings
14
Single-Quoted Strings and Escaping Quotes
Concatenating Strings……,,.,.,
欢迎加入非盈利 Pyt hor学习交流编程Q群783462347,群里免费提供5004本 Pyt hoη书籍
CONteNtS
String Representations, str and repr
16
ong Strings, Raw Strings, and bytes
17
A Quick Summary.………22
New Functions in This chapter.......................23
What now?
Chapter 2: Lists and tuples
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
25
Sequence Overview
25
Common Sequence Operations
26
Indexing….,26
Slicing
28
Adding sequences
30
Multiplication
Membership
32
Length, Minimum, and Maximum
33
Lists: Python's Workhorse.mmmananannamemamamamnnnnananannmamamamamninananan 34
The list function…
Basic list operations
List methods∴
Tuples: Immutable Sequences..
A Quick Summary
New Functions in This Chapter
332444
What now?
Chapter 3: Working with Strings
5
Basic String Operations
String formatting the short version
String Formatting: The Long version
Replacement field Names
55444
Basic conversions…
Width, Precision, and Thousands separators
Signs, Alignment, and Zero-Padding
欢迎加入非盈利 Pyt hor学习交流编程Q群783462347,群里免费提供5004本 Pyt hoη书籍
CONTENTS
String Methods
52
center
53
find
.53
lower
replace
olit
55
stri
56
translate
日日B面日日日自面日日日面日日B面日日日自面日日面B自面日日日B面日面目面日目面日面面日面日日面面日面重日日面日面日面日面日面面日面日自日面日面重日日面日面日
56
Is My String
A Quick Summary.
New Functions in This chapter
What now?
158
Chapter 4: Dictionaries: When Indices Won't Do
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
59
Dictionary Uses
59
Creating and Using Dictionaries
The dict function,……60
Basic Dictionary Operations .......6
String Formatting with Dictionaries
Dictionary Methods .
A Quick Summary…,,…,
70
New Functions in This chapter
What now?
Chapter 5: Conditionals, Loops, and Some Other Statements
n71
More about print and import
Printing Multiple arguments..
mporting Something as Something Else……
2
Assignment Magic.
173
Sequence Unpacking…
Chained assignments…
面日面B面日面面日面面B日面日面日日面面日B面面日面面正面日面面B面面面日面面B量
75
Augmented assignments ..................................................................................................75
欢迎加入非盈利 Pyt hor学习交流编程Q群783462347,群里免费提供5004本 Pyt hoη书籍
CONTENTS
Blocks: The Joy of Indentation
76
Conditions and conditional statements
So Thats what those boolean values are for
668
Conditional execution and the if statement
else clauses
,78
elif clauses
79
Nesting B|cks…,,,
More complex conditio
79
84
oops.n.
85
While l00ps…
for Loops
86
Iterating Over Dictionaries
87
Some iteration utilities
87
Breaking out of Loops
else Clauses in Loops…
92
Comprehensions--Slightly Loopy
92
And three for the road
94
Nothing Happened
Deleting with del
94
Executing and evaluating strings with exec and eval
96
A Quick Summary.
98
New Functions in This chapter.……
What now?
Chapter 6: Abstraction.m mammmmmmmmnmmn 101
Laziness is a virtue
,101
Abstraction and structure
,102
Creating Your Own Functions
102
Documenting Functions.....................
103
Functions That Aren t Really Functions
104
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.