1. 首页
  2. 编程语言
  3. Python
  4. python基础教程第三版

python基础教程第三版

上传者: 2019-05-15 19:08:48上传 PDF文件 5.96MB 热度 29次
英文版python教程,高清版,章节清晰,字体清晰。英文版python教程,高清版,章节清晰,字体清晰。英文版python教程,高清版,章节清晰,字体清晰。英文版python教程,高清版,章节清晰,字体清晰。英文版python教程,高清版,章节清晰,字体清晰。Beginning Python: From Novice to ProfessionalMagnus Lie hetlandTrondheim, NorwayISBN13(pbk):978-1-48420029-2SBN-l3( electronic):978-1-4842-0028-5DOI10.1007/978-1-4842-0028-5Library of congress Control Number: 2017934891Copyright o 2017 by Magnus Lie HetlandThis work is subject to copyright All rights are reserved by the Publisher, whether the whole or part of thematerial is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitationbroadcasting, reproduction on microfilms or in any other physical way, and transmission or information storageand retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known orhereafter developedTrademarked names, logos, and images may appear in this book. Rather than use a trademark symbol withevery occurrence of a trademarked name, logo, or image we use the names, logos, and images only in aneditorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademarkThe use in this publication of trade names, trademarks, service marks, and similar terms, even if they arenotidentified as such, is not to be taken as an expression of opinion as to whether or not they are subject toproprietary rightsWhile 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 oromissions that may be made. The publisher makes no warranty, express or implied, with respect to thematerial contained hereinManaging Director: Welmoed SpahrLead Editor: Steve AnglinDevelopment Editor: Matthew MoodieTechnical reviewer: michael ThomasCoordinating editor: Mark PowersCopy Editor: Kim WimpsettCompositor: SPi GlobalIndexer: SPi globalArtist: SPi globaCover image designed by shutterstockDistributed 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-ny@springersbmcomorvisitwww.springeronline.comApressmediaLlcisaCaliforniaLlcandthesolemember(owner) is Springer Science Business Media Finance Inc(SSBM Finance Inc). SSBM Finance Inc is aDelaware corporationForinformationontranslationspleasee-mailrights@apress.com,orvisitwww.apress.com/us/services/rights-permissionApress titles may be purchased in bulk for academic, corporate, or promotional use eBook versionslicenses are also available for most titles for more information reference our print and ebook bulk sales webpageatwww.apress.com/bulk-salesAny source code or other supplementary material referenced by the author in this book is available to readersfordownloadorcloningatGithubviathebooksproductpagelocatedatwww.apress.com/9781484200292Formoredetailedinformationpleasevisithttp://www.apress.com/us/services/source-codePrinted on acid-free paperFor Kiersti and Tor.Contents at a glanceAbout the author…nxvAbout the technical reviewer■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■XXVIPreface■■■■■■IntroductionChapter 1: Instant Hacking: The basics amaammmmmmmman 1Chapter 2: Lists and tuples meat■■■■■口■■■■■■■■■口■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■■■■■■■■■■■■■■■■■■25Chapter 3: Working with Strings■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■45Chapter 4: Dictionaries: When Indices Won't Do een■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■59Chapter 5: Conditionals, Loops, and Some other Statements mmmmmmmm 71Chapter 6: Abstraction mmmmmmmmmmmmmmmmmn 101Chapter 7: More Abstraction■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■129Chapter 8: Exceptions.mmmtn149Chapter 9: Magic Methods Properties, and lteratorsmmmm 163Chapter 10: Batteries Includedu195Chapter 11: Files and stuffa241Chapter 12: Graphical User Interfaces■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■253Chapter 13: Database Support.Chapter 14: Network Programming mmmmmmmanmammmmm 273Chapter 15: Python and the Web ammerman 289Chapter 16: Testing, 1-2-3mmHBBRBBBIB BEEBBEEB BEIBIRRIBMMEIIIIEIRIIIIIIRIREIIRI 307CONTENTS ATA GLANCEChapter 17: Extending Pythonu321Chapter 18: Packaging Your Programsmmmaa■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■337Chapter 19: Playful Programmingn343Chapter 20: Project 1: Instant Markup353Chapter21: Project 2: Painting a Pretty Picture.,,,,……,,,,,…373Chapter 22: Project 3: XML for All Occasions aaIn 383Chapter 23: Project 4: In the News. mmaa mmmmaan 397Chapter 24: Project 5: A Virtual Tea Party409Chapter 25: Project 6: Remote Editing with CGI■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■425Chapter 26: Project 7: Your Own Bulletin Board435Chapter 27: Project 8: File sharing with XML-RPCmmmmnmm, 451Chapter 28: Project 9: File sharing ll-Now with gUi!aaat■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■467Chapter 29: Project 10: Do-lt-Yourself Arcade Game aaa475Appendix A: The short Versionn495Appendix B: python Reference503Indexummmmm 519ContentsAbout the author…nxvAbout the technical reviewer■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■XXVIPreface■■■■■■IntroductionChapter 1: Instant Hacking: The basics amaammmmmmmman 1The Interactive InterpreterAlgo...What?…Numbers and ExpressionsHexadecimal octals and binary .Variables23556Statements…Getting Input from the UserFunctions6789Modulescmath and Complex Numbers ..tem. 10Back to the futureSaving and Executing Your Programs.Running Your Python Scripts from a Command Prompt .Making Your Scripts Behave Like Normal Programs....................... 13Comments…14Strings14Single-Quoted Strings and Escaping QuotesConcatenating StringsCONteNtSString Representations, str and repr16ong Strings, Raw Strings, and bytes7A Quick Summary.………22New Functions in This chapter.......................23What now?Chapter 2: Lists and tuples■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■25Sequence Overview25Common Sequence Operations26Indexing….,26Slicing28Adding sequences30MultiplicationMembership32Length, Minimum, andLists: Python's Workhorse.mmmananannamemamamamnnnnananannmamamamamninananan 34The list function…Basic list operationsList methods∴Tuples: Immutable Sequences..A Quick SummaryNew Functions in This Chapter332444What now?Chapter 3: Working with Strings5Basic String OperationsString formatting the short versionString Formatting: The Long versionReplacement field Names55444Basic conversions…Width, Precision, and Thousands separatorsSigns, Alignment, and Zero-PaddingCONTENTSString Methods52center53find.53lowerreplace.…,…,olit55trip56translate日日B面日日日自面日日日面日日B面日日日自面日日面B自面日日日B面日面目面日目面日面面日面日日面面日面重日日面日面日面日面日面面日面日自日面日面重日日面日面日56Is My StringA Quick Summary.New Functions in This chapterWhat now?,…58Chapter 4: Dictionaries: When Indices Won't Do■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■59Dictionary Uses159Creating and Using DictionariesnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnDnDnnDDDnDDDnDDnDnnDDID60The dict function,………60Basic Dictionary Operations .......6String Formatting with DictionariesDictionary Methods......................... 6A Quick Summary…,,…,70New Functions in This chapterWhat now?,…70Chapter 5: Conditionals, Loops, and Some Other Statementsn71More about print and importPrinting Multiple arguments..mporting Something as Something Else……2Assignment Magic.173Sequence Unpacking…Chained assignments…面日面B面日面面日面面B日面日面日日面面日B面面日面面正面日面面B面面面日面面B量75Augmented assignments ..................................................................................................75CONTENTSBlocks: The Joy of Indentation76Conditions and conditional statements………76So Thats what those boolean values are for76Conditional execution and the if statement8elseelif clauses79Nesting Blocks.More Complex Conditions79Assertion84oops.n.85While l00ps…for LoopsIterating over DictionariesSome iteration utilities,87Breaking out of Loopselse Clauses in Loops…92Comprehensions--Slightly Loopy92And three for the road94Nothing Happened94Deleting with del94Executing and evaluating strings with exec and eval96A Quick Summary.98New Functions in This chapterWhat now?Chapter 6: Abstraction.m mammmmmmmmnmmn 101Laziness is a virtue,101Abstraction and structure,102Creating Your Own Functions102Documenting Functions.........................103Functions That Aren 't Really Functions.104
用户评论