作者:empty 页数:137 出版社:empty |
If you do much work on computers, eventually you find that there's some task you'd like to automate.For example,you may wish to perform a search-and-replace over a large number of text files, or rename and rearrange a bunch ofphoto fles in a complicated way.Perhaps you d like to write a small custom database.or a specialized GUI application,or a simple game氏认如果更程多工件、布望有少务成.,你可飞在大品大卡文牛中国行摆作,许元让是的方生名并摇一托图文件能二个小的定训渴卉, 成有的GUI应序成沪油平的资成.If you're a professional software developer, you may have to work with several C/C++/Java libraries but find the usualwrite/compile/test/re-compile cycle is too slow.Perhaps you'rewriting a testsuite for such a library and find writingthe testingcode a tedious task.Or maybe you've written a program that could use an extension I anguage, and youdon't want to design and implement a whole new language for your application.年八专的技牛开成, 可能用/-C/C++/Java产二作.伊发的然/济//飞环太了、开品你补个片锅与应的试代如足发是一个炫人的儿,点对饰在2j一八杆计的停、而快不给你的应品认:个实一门全为计Python is just the language for you.Python就是体需您的话言,You could write a UNix shellscript or Windows bate h files for some of these tasks, but shell xer ipts are best at movingaround files and changing textdata, not well-suited for GUI applications or games.You could write aC/C++Javaprogram, but it can take alot of development time to get even a first-draft program.Python is simpler to use, availableon Windows.MacOSX.and UNIX operating systems, and will help you get the job done more quickly.你能够针付一任务UNIX shell.p水者Windows-比欠飞件, 但是脚本语武移动定外心保六数型:不适合GUI瓶序成者并哦, 体能上C/C++/Java/.但足达些技术就足发单的和产色安上的开发时间, 论A Windows.MacOSX点UNIX摆作系统.:Python常另于司, 可帮长的完成任务、Python is simple to use, but it is a real programming language.offering much more structure and support for large pro-grams than shell scripts or batch files can offer.On the other hand.Python also offers much more er or checking thanC.and, being avery-high-level language, it has high-level datatypes builtin, such as flexible arrays and dictionaries.Because of its more general datatypes Python is applicable to a much larger problem domain than Awk or even Perl,yet many things are atleast as easy in Python as in those languagesPython容易上宁、2它足一门止的汇沧语吉::E对Shell:它提的中对入尚的村和网染多的多了一方面、它提供了出C安的检仓,一且、为一门素高的经言:它有的高共:可教汇中尖,加通读C长实想的识,些.工.作可能让六干上儿天的-间,小定的水保型, Python适合HS Awk甚天Perl火广的问题行域, 在它的依多领成、Python少比印的语一波苏可祠.Python allows you to split your program into modules that can be reused in other Python programs.It comes with alarge collection of standard modules that you can use as the basis of your programs-or as examples to start leamingto program in Python.Some of these modules provide things like file I/O, system calls, sockets, and even interfaces tographical userinterface toolkits like Tk.Python.让你把自己品5分成不同头, 以在其食品Python 50中多、这汗饰可以让自己的斤些个一个大行门电示Python Pyt bon朱成了一共文牛I/O.系识:sockets.主Tk这纤的图形工具摆r.Python is an interpreted language.which can save you considerable time during program development because nocompilation and linking is necessary.The interpreter can be used interactively, which makes it easy to experiment withfeatures of the language.to write throw-away programs, or to test functions during bottom-up program development.It is also a handy desk calculator.Python是一7评型宝:卜为不质计接询问, 它以书者下一发问, 齐品以定或用,就小很方便好中的各沙航成化于棉写发布用七小.与让行自下而二开发还可公是一个竹子叮用的计产著Python enables programs to be written compactly and read ably.Programs written in Python are typically much shorterthan equivalent C, C++, or Java programs, for several reasons:Py hon i出衣e很强程, iPy hon 2的汇常比F薄的C、C++Java点.为几个原:Python is extensible:if you know howto program inC it is easy to add a new builtin function or module to theinterpreter.cit her to perform critical operations at maximum speed.or to link Python programs to libraries that mayonly be available in binary form(such as a vendor-speci tic graphics library) .Once you are really hooked.you canlnk the Python interpreter into an application wit lenin C and use it as an extension or command language for that·the high-level datatypes allow you to express complex operations in a single statement:·statement grouping is done by indentation instead of beginning and ending brackets;·no variable or argument declarations are necessary.·高书心你可以一个单的落中展达:术道杂的:·评句约汇识衣货于面_begin/end R,·不柔实成产明application.Py hon生汽会C小习很房为防能化、255.5大度:或考Python部接别介的二到中架的二:米人专的商斗形所) .华产真正起志这一切了, 你款以Python其成(:C写成的E序:把Python当这个程片的扩成命令行计.By the way.the language is named after the BBC show“Monty Python's Flying Circus and has nothing to do withnasty re piles.Making references to Monty Python skits in documentation is not only allowed.it is encouraged!N1说一下、这八语一的.然水于BBC的“Monty Python's Flying Circus”节习, 我的心击有任养、在文门月Monty Python从不证是免片的:旦飞定到!Now that you are all excited about Python.you'll want to examine it in some more detail.Since the best way to leama language is to use it.the tutorial invites you to play with the Python interpreter as you read.在我代了了Python所对激动人心系码:大成化越行的试试它了, 学习-汇语下好的序汽就是饮同它, 如你所到的、卡文合乐Python¥洋、In the next chapter.the mechani es of using the interpreter are explained.This is rather mundane information, buressential for trying out the examples shown later.7.-心,我们让减说语证器的用法,这没有么刊和的民容:下于我们妇后面长示的例子.2Chapter 1.Whet ng Your Appetite开
The rest of the tutorial introduces vu rious features of the Python language and system through examples, beginningwith simple expressions, statements and datatypes.through functions and modules, and finally touching upon ad-vanced concepts like exceptions and user-defined classes.打宝部分门十产绍了Python海三利燕就的各种时份, 是爷生成, 好和派,F飞上和块,我后是计常和自定义点法卡高内装.
MoembstgFunonsr a设定义
4 DataStructures据构
4.1More on Lists沃人衣.
42The del statement del计向
4.6Looping Techniques环技米
.9More on Condtions深八a
4.8Comparing Sequences and Other Types不可*.的位
5 Modules模
5.1More on Modules深入
5.2Standard Modules卡
5.3The dir() Function dir() &:
34Packages包+.4.4
6 Input and Output输入和哈出
6.1Fancier Output Formatting设计棕旧式
6.2Reading and Writing Files if写火件53
7 Errors and Exceptions错以和共
7.1Syntax Errors法义.
72Exceptions+常
74Raising Exceptions出产常
7.6Det in ing Clean-up Actions宋义行为
7.7Pre de lined Clean-up Act ons预定义清进行为
8 Classes
8.1A Word About Terminology大
8.3A First Look at Classes书识失
8.4Random Rer arks-291,
8.5Inheritance As衣
8.6Private Variables都有
8.7Odds and Ends章
8.8Exceptions Are Classes Too开常也
8.9 Iterators泡代器
8.10 Generators生成&
8.11 Generator Expressions主成器表证式
9 Brief Tour of the Standard Library而准库低总
9.1OperatingSystem Interface养系岛试心
92File Wildcards文科
9.3CommandLine Arguments中令行参彩
9.4ErorouputRediecnandProam Tem into nw心上更定内
95String Pattern Matchin