A-Python-Book-Beginning-Python-Advanced-Python-and-Python-Exercises.pdf
《A-Python-Book-Beginning-Python-Advanced-Python-and-Python-Exercises.pdf》由会员分享,可在线阅读,更多相关《A-Python-Book-Beginning-Python-Advanced-Python-and-Python-Exercises.pdf(278页珍藏版)》请在文库网上搜索。
1、APythonBookAPythonBook:BeginningPython,AdvancedPython,andPythonExercisesAuthor:DaveKuhlmanContact:dkuhlmandavekuhlman.orgAddress:http:/www.davekuhlman.orgPage1APythonBookRevision1.3aDateDecember15,2013CopyrightCopyright(c)2009DaveKuhlman.AllRightsReserved.ThisdocumentissubjecttotheprovisionsoftheOpe
2、nSourceMITLicensehttp:/www.opensource.org/licenses/mitlicense.php.AbstractThisdocumentisaselflearningdocumentforacourseinPythonprogramming.Thiscoursecontains(1)apartforbeginners,(2)adiscussionofseveraladvancedtopicsthatareofinteresttoPythonprogrammers,and(3)aPythonworkbookwithlotsofexercises.Page2AP
3、ythonBookContents1Part1BeginningPython.101.1IntroductionsEtc.101.1.1Resources.111.1.2AgeneraldescriptionofPython.121.1.3InteractivePython.151.2Lexicalmatters.151.2.1Lines.151.2.2Comments.161.2.3Namesandtokens.161.2.4Blocksandindentation.161.2.5Docstrings.171.2.6Programstructure.171.2.7Operators.181.
4、2.8Alsosee.191.2.9Codeevaluation.191.3Statementsandinspectionpreliminaries.201.4Builtindatatypes.211.4.1Numerictypes.211.4.2Tuplesandlists.211.4.3Strings.241.4.3.1Thenewstring.formatmethod.261.4.3.2Unicodestrings.271.4.4Dictionaries.291.4.5Files.321.4.6Otherbuiltintypes.351.4.6.1TheNonevalue/type.35
5、1.4.6.2Booleanvalues.361.4.6.3Setsandfrozensets.361.5FunctionsandClassesAPreview.361.6Statements.371.6.1Assignmentstatement.371.6.2importstatement.391.6.3printstatement.411.6.4if:elif:else:statement.431.6.5for:statement.441.6.6while:statement.48Page3APythonBook1.6.7continueandbreakstatements.481.6.8
6、try:except:statement.491.6.9raisestatement.511.6.10with:statement.521.6.10.1Writingacontextmanager.521.6.10.2Usingthewith:statement.531.6.11del.541.6.12casestatement.551.7Functions,Modules,Packages,andDebugging.551.7.1Functions.551.7.1.1Thedefstatement.551.7.1.2Returningvalues.551.7.1.3Parameters.56
7、1.7.1.4Arguments.561.7.1.5Localvariables.571.7.1.6Otherthingstoknowaboutfunctions.571.7.1.7Globalvariablesandtheglobalstatement.581.7.1.8Docstringsforfunctions.601.7.1.9Decoratorsforfunctions.601.7.2lambda.611.7.3Iteratorsandgenerators.621.7.4Modules.671.7.4.1Docstringsformodules.681.7.5Packages.681
8、.8Classes.691.8.1Asimpleclass.691.8.2Definingmethods.701.8.3Theconstructor.701.8.4Membervariables.701.8.5Callingmethods.711.8.6Addinginheritance.711.8.7Classvariables.721.8.8Classmethodsandstaticmethods.721.8.9Properties.741.8.10Interfaces.751.8.11Newstyleclasses.751.8.12Docstringsforclasses.771.8.1
9、3Privatemembers.771.9SpecialTasks.771.9.1Debuggingtools.77Page4APythonBook1.9.2Fileinputandoutput.781.9.3Unittests.801.9.3.1Asimpleexample.801.9.3.2Unittestsuites.811.9.3.3Additionalunittestfeatures.831.9.3.4GuidanceonUnitTesting.851.9.4doctest.851.9.5ThePythondatabaseAPI.871.9.6InstallingPythonpack
10、ages.881.10MorePythonFeaturesandExercises.892Part2AdvancedPython.902.1IntroductionPython201(Slightly)AdvancedPythonTopics.902.2RegularExpressions.902.2.1Definingregularexpressions.902.2.2Compilingregularexpressions.912.2.3Usingregularexpressions.912.2.4Usingmatchobjectstoextractavalue.922.2.5Extract
11、ingmultipleitems.932.2.6Replacingmultipleitems.942.3IteratorObjects.962.3.1ExampleAgeneratorfunction.982.3.2ExampleAclasscontainingageneratormethod.1002.3.3ExampleAniteratorclass.1022.3.4ExampleAniteratorclassthatusesyield.1042.3.5ExampleAlistcomprehension.1052.3.6ExampleAgeneratorexpression.1052.4U
12、nitTests.1062.4.1Definingunittests.1062.4.1.1Createatestclass.1062.5ExtendingandembeddingPython.1092.5.1Introductionandconcepts.1092.5.2Extensionmodules.1102.5.3SWIG.1122.5.4Pyrex.1152.5.5SWIGvs.Pyrex.1202.5.6Cython.1202.5.7Extensiontypes.1222.5.8Extensionclasses.1222.6Parsing.1222.6.1Specialpurpose
13、parsers.123Page5欢迎加入非盈利Py t h o n 学习交流编程QQ群783462347,群里免费提供500+本Py t h o n 书籍!APythonBook2.6.2Writingarecursivedescentparserbyhand.1242.6.3Creatingalexer/tokenizerwithPlex.1312.6.4Asurveyofexistingtools.1412.6.5CreatingaparserwithPLY.1412.6.6Creatingaparserwithpyparsing.1482.6.6.1Parsingcommadelimit
14、edlines.1482.6.6.2Parsingfunctors.1492.6.6.3Parsingnames,phonenumbers,etc.1502.6.6.4Amorecomplexexample.1512.7GUIApplications.1532.7.1Introduction.1532.7.2PyGtk.1532.7.2.1Asimplemessagedialogbox.1532.7.2.2Asimpletextinputdialogbox.1562.7.2.3Afileselectiondialogbox.1582.7.3EasyGUI.1602.7.3.1AsimpleEa
15、syGUIexample.1612.7.3.2AnEasyGUIfileopendialogexample.1612.8GuidanceonPackagesandModules.1612.8.1Introduction.1612.8.2ImplementingPackages.1622.8.3UsingPackages.1622.8.4DistributingandInstallingPackages.1622.9EndMatter.1642.9.1AcknowledgementsandThanks.1642.9.2SeeAlso.1643Part3PythonWorkbook.1653.1I
16、ntroduction.1653.2LexicalStructures.1653.2.1Variablesandnames.1653.2.2Linestructure.1673.2.3Indentationandprogramstructure.1683.3ExecutionModel.1693.4BuiltinDataTypes.1703.4.1Numbers.1703.4.1.1Literalrepresentationsofnumbers.1713.4.1.2Operatorsfornumbers.1733.4.1.3Methodsonnumbers.1753.4.2Lists.1753
17、.4.2.1Literalrepresentationoflists.176Page6欢迎加入非盈利Py t h o n 学习交流编程QQ群783462347,群里免费提供500+本Py t h o n 书籍!APythonBook3.4.2.2Operatorsonlists.1783.4.2.3Methodsonlists.1783.4.2.4Listcomprehensions.1803.4.3Strings.1823.4.3.1Characters.1833.4.3.2Operatorsonstrings.1843.4.3.3Methodsonstrings.1853.4.3.4Raw
18、strings.1873.4.3.5Unicodestrings.1883.4.4Dictionaries.1903.4.4.1Literalrepresentationofdictionaries.1903.4.4.2Operatorsondictionaries.1913.4.4.3Methodsondictionaries.1923.4.5Files.1953.4.6Afewmiscellaneousdatatypes.1973.4.6.1None.1973.4.6.2ThebooleansTrueandFalse.1973.5Statements.1983.5.1Assignments
19、tatement.1983.5.2printstatement.2003.5.3if:statementexercises.2013.5.4for:statementexercises.2023.5.5while:statementexercises.2053.5.6breakandcontinuestatements.2063.5.7Exceptionsandthetry:except:andraisestatements.2073.6Functions.2103.6.1Optionalargumentsanddefaultvalues.2113.6.2Passingfunctionsasa
20、rguments.2133.6.3Extraargsandkeywordargs.2143.6.3.1Orderofarguments(positional,extra,andkeywordargs).2163.6.4Functionsandducktypingandpolymorphism.2163.6.5Recursivefunctions.2173.6.6Generatorsanditerators.2193.7Objectorientedprogrammingandclasses.2233.7.1Theconstructor.2243.7.2InheritanceImplementin
21、gasubclass.2253.7.3Classesandpolymorphism.2273.7.4Recursivecallstomethods.2283.7.5Classvariables,classmethods,andstaticmethods.2303.7.5.1Decoratorsforclassmethodandstaticmethod.233Page7欢迎加入非盈利Py t h o n 学习交流编程QQ群783462347,群里免费提供500+本Py t h o n 书籍!APythonBook3.8AdditionalandAdvancedTopics.2343.8.1Dec
22、oratorsandhowtoimplementthem.2343.8.1.1Decoratorswitharguments.2353.8.1.2Stackeddecorators.2363.8.1.3Morehelpwithdecorators.2383.8.2Iterables.2393.8.2.1AfewpreliminariesonIterables.2393.8.2.2Morehelpwithiterables.2403.9ApplicationsandRecipes.2403.9.1XMLSAX,minidom,ElementTree,Lxml.2413.9.2Relational
23、databaseaccess.2493.9.3CSVcommaseparatedvaluefiles.2553.9.4YAMLandPyYAML.2563.9.5Json.2584Part4GeneratingPythonBindingsforXML.2604.1Introduction.2604.2Generatingthecode.2614.3UsingthegeneratedcodetoparseandexportanXMLdocument.2634.4Somecommandlineoptionsyoumightwanttoknow.2634.5Thegraphicalfrontend.
24、2644.6Addingapplicationspecificbehavior.2654.6.1Implementingcustomsubclasses.2654.6.2UsingthegeneratedAPIfromyourapplication.2664.6.3Acombinedapproach.2674.7Specialsituationsanduses.2694.7.1Generic,typeindependentprocessing.2694.7.1.1Step1generatethebindings.2704.7.1.2Step2addapplicationspecificcode
25、.2704.7.1.3Step3writeatest/driverharness.2744.7.1.4Step4runthetestapplication.2764.8Somehints.2764.8.1ChildrendefinedwithmaxOccursgreaterthan1.2764.8.2Childrendefinedwithsimplenumerictypes.2774.8.3Thetypeofanelementscharactercontent.2774.8.4Constructorsandtheirdefaultvalues.277Page8欢迎加入非盈利Py t h o n
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Python Book Beginning Advanced and Exercises
链接地址:https://www.wenkunet.com/p-5710238.html