資源描述:
《python快速入門--byarmand》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、PythonQuicklyStartGuide1************************************************************************************INSTRUCTIONThistipsisanoteafterreadingbooksasfollow:(secondedition)Ittakesmeaboutaweektoknowwellstyleofpython-program.C-langu
2、ageandVB–languagehavebeenmywork-toolbeforethis.pythonissimpleandniceaswellasworth-learning.*************************************************************************************Redfortitle___Lightblueforimportantcode___Lightgreenforimportantinformation___Contents1BasicusageofPython12datastructurei
3、nPython33List-slaveofpython54TupleString-unmutable95Dictionary--whenindexisnotgood106Conditioncycleandotherstatement137Abstraction—function188MoreAbstract219exceptionhandling2710magicmethod2911standardlibrary3112fileoperation3213GUI3714Package-about__init__4142PythonQuicklyStartGuide1************
4、*************************************************************************1BasicusageofPythonPrintxX=input(“plsinputthevalue:”)importmathshouldalwaysusemodulebythiswaymath.floor(32.9)int(math.floor(32.9))frommathimportsqrtsqrt(9)name=raw_input("what'syourname?:")print"hello."+name+"!"#hereisexplan
5、atorynotedoublequotationmarksisequaltosingleoneinstringusage.exp:print"let'sgo"print'let'sto'print""hello,world"shesaid"stringsmerge:"let'sknow""aboutyou"or42PythonQuicklyStartGuide1x="hello"y="everyone"x+y>>>"helloworld"'helloworld'>>>10000L10000L>>>print"helloworld"helloworld>>>print10000L10
6、000Butsometimesweneedtoknowthedetailsofthevalueprinted.>>>printrepr("helloworld")'helloworld'>>>printrepr(10000L)10000L>>>printstr("hello,world")hello,world>>>printstr(10000L)10000functioninputandraw_input:name=input("plsinputyourname:")--youneedtoinput"wangwei"name=raw_input("plsinputyourname:")
7、--youneedtoinputwangwei42PythonQuicklyStartGuide12datastructureinPythonMostimportantdatastructureofpythonissequencewhichincludelist(1)tuple(2)string(3)andsoon.listcanbemodifiedandtuplecan'tbemodified.listcanreplacetupl