图书介绍
PYTHON编程 上 第4版 影印版PDF|Epub|txt|kindle电子书版本网盘下载
![PYTHON编程 上 第4版 影印版](https://www.shukui.net/cover/34/30999005.jpg)
- (美)鲁兹(MARK LUTZ)著 著
- 出版社: 南京:东南大学出版社
- ISBN:7564126872
- 出版时间:2011
- 标注页数:767页
- 文件大小:115MB
- 文件页数:807页
- 主题词:
PDF下载
下载说明
PYTHON编程 上 第4版 影印版PDF格式电子书版下载
下载的文件为RAR压缩包。需要使用解压软件进行解压得到PDF格式图书。建议使用BT下载工具Free Download Manager进行下载,简称FDM(免费,没有广告,支持多平台)。本站资源全部打包为BT种子。所以需要使用专业的BT下载软件进行下载。如BitComet qBittorrent uTorrent等BT下载工具。迅雷目前由于本站不是热门资源。不推荐使用!后期资源热门了。安装了迅雷也可以迅雷进行下载!
(文件页数 要大于 标注页数,上中下等多册电子书除外)
注意:本站所有压缩包均有解压码: 点击下载压缩包解压工具
图书目录
Part Ⅰ.The Beginning3
1.A Sneak Preview3
"Programming Python:The Short Story”3
The Task4
Step 1:Representing Records4
Using Lists4
Using Dictionaries9
Step 2:Storing Records Persistently14
Using Formatted Files14
Using Pickle Files19
Using Per-Record Pickle Files22
Using Shelves23
Step 3:Stepping Up to OOP26
Using Classes27
Adding Behavior29
Adding Inheritance29
Refactoring Code31
Adding Persistence34
Other Database Options36
Step 4:Adding Console Interaction37
A Console Shelve Interface37
Step 5:Adding a GUI40
GUI Basics40
Using OOP for GUIs42
Getting Input from a User44
A GUI Shelve Interface46
Step 6:Adding a Web Interface52
CGI Basics52
Running a Web Server55
Using Query Strings and urllib57
Formatting Reply Text59
A Web-Based Shelve Intefface60
The End of the Demo69
Part Ⅱ.System Programming73
2.System Tools73
"The os.path to Knowledge"73
Why Python Here?73
The Next Five Chapters74
System Scripting Overview75
Python System Modules76
Module Documentation Sources77
Paging Documentation Strings78
A Custom Paging Script79
String Method Basics80
Other String Concepts in Python 3.X:Unicode and bytes82
File Operation Basics83
Using Programs in Two Ways84
Python Library Manuals85
Commercially Published References86
Introducing the sys Module86
Platforms and Versions86
The Module Search Path87
The Loaded Modules Table88
Exception Details89
Other sys Module Exports90
Introducing the os Module90
Tools in the os Module90
Administrative Tools91
Portability Constants92
Common os.path Tools92
Running Shell Commands from Scripts94
Other os Module Exports100
3.Script Execution Context103
"I'd Like to Have an Argument,Please"103
Current Working Directory104
CWD,Files,and Import Paths104
CWD and Command Lines106
Command-Line Arguments106
Parsing Command-Line Arguments107
Shell Environment Variables109
Fetching Shell Variables110
Changing Shell Variables111
Shell Variable Fine Points:Parents,putenv,and getenv112
Standard Streams113
Redirecting Streams to Files and Programs114
Redirected Streams and User Interaction119
Redirecting Streams to Python Objects123
The io.StringIO and io.BytesIO Utility Classes126
Capturing the stderr Stream127
Redirection Syntax in Print Calls127
Other Redirection Options:os.popen and subprocess Revisited128
4.Fileand Directory Tools135
"Erase Your Hard Drive in Five Easy Steps!"135
File Tools135
The File Object Modelin Python 3.X136
Using Built-in File Objects137
Binary and Text Files146
Lower-Level File Tools in the os Module155
File Scanners160
Directory Tools163
Walking One Directory164
Walking Directory Trees168
Handling Unicode Filenames in 3.X:listdir,walk,glob172
5.Parallel System Tools177
"Telling the Monkeys What to Do"177
Forking Processes179
The fork/exec Combination182
Threads186
The_thread Module189
The threading Module199
The queue Module204
Preview:GUIs and Threads208
More on the Global Interpreter Lock211
Program Exits213
sys Module Exits214
os Module Exits215
Shell Command Exit Status Codes216
Process Exit Status and Shared State219
Thread Exits and Shared State220
Interprocess Communication222
Anonymous Pipes224
Named Pipes(Fifos)234
Sockets:A First Look236
Signals240
The multiprocessing Module243
Why multiprocessing?243
The Basics:Processes and Locks245
IPC Tools:Pipes,Shared Memory,and Queues248
Starting Independent Programs254
And Much More256
Why multiprocessing?The Conclusion257
Other Ways to Start Programs258
The os.spawn Calls258
The os.startfile call on Windows261
A Portable Program-Launch Framework263
Other System Tools Coverage268
6.Complete System Programs271
"The Greps of Wrath"271
A Quick Game of"Find the Biggest Python File"272
Scanning the Standard Library Directory272
Scanning the Standard Library Tree273
Scanning the Module Search Path274
Scanning the Entire Machine276
Printing Unicode Filenames279
Splitting and Joining Files282
Splitting Files Portably283
Joining Files Portably286
Usage Variations289
Generating Redirection Web Pages292
Page Template File293
Page Generator Script294
A Regression Test Script297
Running the Test Driver299
Copying Directory Trees304
Comparing Directory Trees308
Finding Directory Differences309
Finding Tree Differences311
Running the Script314
Verifying Backups316
Reporting Differences and Other Ideas317
Searching Directory Trees319
Greps and Globs and Finds320
Rolling Your Own find Module321
Cleaning Up Bytecode Files324
A Python Tree Searcher327
Visitor:Walking Directories"++"330
Editing Files in Directory Trees(Visitor)334
Global Replacements in Directory Trees(Visitor)336
Counting Source Code Lines(Visitor)338
Recoding Copies with Classes(Visitor)339
Other Visitor Examples(External)341
Playing Media Files343
The Python webbrowser Module347
The Python mimetypes Module348
Running the Script350
Automated Program Launchers(External)351
Part Ⅲ.GUI Programming355
7.Graphical User Interfaces355
"Here's Looking at You,Kid"355
GUI Programming Topics355
Running the Examples357
Python GUI Development Options358
tkinter Overview363
tkinter Pragmatics363
tkinter Documentation364
tkinter Extensions364
tkinter Structure366
Climbing the GUI Learning Curve368
"Hello World"in Four Lines(or Less)368
tkinter Coding Basics369
Making Widgets370
Geometry Managers370
Running GUI Programs371
tkinter Coding Alternatives372
Widget Resizing Basics373
Configuring Widget Options and Window Titles375
One More for Old Times'Sake376
Packing Widgets Without Saving Them377
Adding Buttons and Callbacks379
Widget Resizing Revisited:Expansion380
Adding User-Defined Callback Handlers382
Lambda Callback Handlers383
Deferring Calls with Lambdas and Object References384
Callback Scope Issues385
Bound Method Callback Handlers391
Callable Class Object Callback Handlers392
Other tkinter Callback Protocols393
Binding Events394
Adding Multiple Widgets395
Widget Resizing Revisited:Clipping396
Attaching Widgets to Frames397
Layout:Packing Order and Side Attachments397
The Packer's Expand and Fill Revisited398
Using Anchor to Position Instead of Stretch399
Customizing Widgets with Classes400
Standardizing Behavior and Appearance401
Reusable GUI Components with Classes403
Attaching Class Components405
Extending Class Components407
Standalone Container Classes408
The End of the Tutorial410
Pvthon/tkinter for Tcl/Tk Converts412
8.A tkinter Tour,Part 1415
"Widgets and Gadgets and GUIs,Oh My!"415
This Chapter's Topics415
Configuring Widget Appearance416
Top-Level Windows419
Toplevel and Tk Widgets421
Top-Level Window Protocols422
Dialogs426
Standard(Common)Dialogs426
The Old-Style Dialog Module438
Custom Dialogs439
Binding Events443
Other bind Events447
Message and Entry448
Message448
Entry449
Laying Out Input Forms451
tkinter"Variables"and Form Layout Alternatives454
Checkbutton,Radiobutton,and Scale457
Checkbuttons457
Radio Buttons462
Scales(Sliders)467
Running GUI Code Three Ways471
Attaching Frames471
Independent Windows476
Running Programs478
Images484
Fun with Buttons and Pictures487
Viewing and Processing Images with PIL491
PIL Basics491
Displaying Other Image Types with PIL493
Creating Image Thumbnails with PIL496
9.A tkinter Tour,Part 2507
"On Today's Menu:Spam,Spam,and Spam"507
Menus507
Top-Level Window Menus508
Frame-and Menubutton-Based Menus512
Windows with Both Menus and Toolbars517
Listboxes and Scrollbars522
Programming Listboxes524
Programming Scroll Bars525
Packing Scroll Bars526
Text528
Programming the Text Widget530
Adding Text-Editing Operations533
Unicode and the Text Widget538
Advanced Text and Tag Operations548
Canvas550
Basic Canvas Operations550
Programming the Canvas Widget551
Scrolling Canvases554
Scrollable Canvases and Image Thumbnails557
Using Canvas Events560
Grids564
Why Grids?564
Grid Basics:Input Forms Revisited565
Comparing grid and pack566
Combining grid and pack568
Making Gridded Widgets Expandable570
Laying Out Larger Tables with grid574
Time Tools,Threads,and Animation582
Using Threads with tkinter GUIs584
Using the after Method585
Simple Animation Techniques588
Other Animation Topics593
The End of the Tour595
Other Widgets and Options595
10.GUI Coding Techniques597
"Building a Better Mousetrap"597
GuiMixin:Common Tool Mixin Classes598
Widget Builder Functions598
Mixin Utility Classes599
GuiMaker:Automating Menus and Toolbars603
Subclass Protocols607
GuiMaker Classes608
GuiMaker Self-Test608
BigGui:A Client Demo Program609
ShellGui:GUIs for Command-Line Tools613
A Generic Shell,Tools Display613
Application-Specific Tool Set Classes615
Adding GUI Frontends to Command Lines617
GuiStreams;Redirecting Streams to Widgets623
Using Redirection for the Packing Scripts627
Reloading Callback Handlers Dynamically628
Wrapping Up Top-Level Window Interfaces630
GUIs,Threads,and Queues635
Placing Data on Queues636
Placing Callbacks on Queues640
More Ways to Add GUIs to Non-GUI Code646
Popping Up GUI Windows on Demand647
Adding a GUI As a Separate Program:Sockets(A Second Look)649
Adding a GUI As a Separate Program:Command Pipes654
The PyDemos and PyGadgets Launchers662
PyDemos Launcher Bar(Mostly External)662
PyGadgets Launcher Bar667
11.Complete GUI Programs671
"Python,Open Source,and Camaros"671
Examples in Other Chapters672
This Chapter's Strategy673
PyEdit:A Text Editor Program/Object674
Running PyEdit675
PyEdit Changes in Version 2.0(Third Edition)682
PyEdit Changes in Version 2.1(Fourth Edition)684
PyEdit Source Code693
PyPhoto:An Image Viewer and Resizer716
Running PyPhoto717
PyPhoto Source Code719
PyView:An Image and Notes Slideshow727
Running PyView727
PvView Source Code732
PyDraw:Painting and Moving Graphics738
Running PyDraw738
PvDraw Source Code738
PyClock:An Analog/Digital Clock Widget747
A Quick Geometry Lesson747
Running PyClock751
PyClock Source Code754
PyToe:A Tic-Tac-Toe Game Widget762
Running PyToe762
PyToe Source Code(External)763
Where to Go from Here766
Part Ⅳ.Internet Programming771
12.Network Scripting771
"Tune In,Log On,and Drop Out"771
Internet Scripting Topics772
Running Examples in This Part of the Book775
Python Internet Development Options777
Plumbing the Internet780
The Socket Layer781
The Protocol Layer782
Python's Internet Library Modules785
Socket Programming787
Socket Basics788
Running Socket Programs Locally794
Running Socket Programs Remotely795
Spawning Clients in Parallel798
Talking to Reserved Ports801
Handling Multiple Clients802
Forking Servers803
Threading Servers815
Standard Library Server Classes818
Multiplexing Servers with select820
Summary:Choosing a Server Scheme826
Making Sockets Look Like Files and Streams827
A Stream Redirection Utility828
A Simple Python File Server840
Running the File Server and Clients842
Adding a User-Intefface Frontend843
13.Client-Side Scripting853
"Socket to Me!"853
FTP:Transferring Files over the Net854
Transferring Files with ffplib854
Using urllib to Download Files857
FTP get and put Utilities860
Adding a User Interfaca867
Transferring Directories with ftplib874
Downloading Site Directories874
Uploading Site Directories880
Refactoring Uploads and Downloads for Reuse884
Transferring Directory Trees with ffplib892
Uploading Local Trees893
Deleting Remote Trees895
Downloading Remote Trees899
Processing Internet Email899
Unicode in Python 3.X and Email Tools900
POP:Fetching Email901
Mail Configuration Module902
POP Mail Reader Script905
Fetching Messages906
Fetching Email at the Interactive Prompt909
SMTP:Sending Email910
SMTP Mail Sender Script911
Sending Messages913
Sending Email at the Interactive Prompt919
email:Parsing and Composing Mail Content921
Message Objects922
Basic email Package Interfaces in Action924
Unicode,Internationalization,and the Python 3.1 email Package926
A Console-Based Email Client947
Running the pymail Console Client952
The mailtools Utility Package956
Initialization File957
MailTool Class958
MailSender Class959
MailFetcher Class967
MailParser Class976
Self-Test Script983
Updating the pymail Console Client986
NNTP:Accessing Newsgroups991
HTTP:Accessing Websites994
The urllib Package Revisited997
Other urllib Interfaces999
Other Client-Side Scripting Options1002
14.The PyMailGUI Client1005
"Use the Source,Luke"1005
Source Code Modules and Size1006
Whv PyMailGUI?1008
Running PyMailGUI1010
Presentation Strategy1010
Major PyMailGUI Changes1011
New in Version 2.1 and 2.0(Third Edition)1011
New in Version 3.0(Fourth Edition)1012
A PyMailGUI Demo1019
Getting Started1020
Loading Mail1025
Threading Model1027
Load Server Interface1030
Offline Processing with Save and Open1031
Sending Email and Attachments1033
Viewing Email and Attachments1037
Email Replies and Forwards and Recipient Options1043
Deleting Email1049
POP Message Numbers and Svnchronization1051
Handling HTML Content in Email1053
Mail Content Internationalization Support1055
Alternative Configurations and Accounts1059
Multiple Windows and Status Messages1060
PyMailGUI Implementation1062
PyMailGUI:The Main Module1063
SharedNames:Program-Wide Globals1066
ListWindows:Message List Windows1067
ViewWindows:Message View Windows1085
messagecache:Message Cache Manager1095
popuputil:General-Purpose GUI Pop Ups1098
wraplines:Line Split Tools1100
html2text:Extracting Text from HTML(Prototype,Preview)1102
mailconfig:User Configurations1105
textConfig:Customizing Pop-Up PyEdit Windows1110
PyMailGUIHelp:User Help Text and Display1111
altconfigs:Configuring for Multiple Accounts1114
Ideas for Improvement1116
15.Server-Side Scripting1125
"Oh,What a Tangled Web We Weave"1125
What's a Server-Side CGI Script?1126
The Script Behind the Curtain1126
Writing CGI Scripts in Python1128
Running Server-Side Examples1130
Web Server Options1130
Running a Local Web Server1131
The Server-Side Examples Root Page1133
Viewing Server-Side Examples and Output1134
Climbing the CGI Learning Curve1135
A First Web Page1135
A First CGI Script1141
Adding Pictures and Generating Tables1146
Adding User Interaction1149
Using Tables to Lay Out Forms1157
Adding Common Input Devices1163
Changing Input Layouts1166
Passing Parameters in Hardcoded URLs1170
Passing Parameters in Hidden Form Fields1172
Saving State Information in CGI Scripts1174
URL Query Parameters1176
Hidden Form Input Fields1176
HTTP"Cookies"1177
Server-Side Databases1181
Extensions to the CGI Model1182
Combining Techniques1183
The Hello World Selector1183
Checking for Missing and Invalid Inputs1190
Refactoring Code for Maintainability1192
Step 1:Sharing Objects Between Pages—A New Input Form1193
Step 2:A Reusable Form Mock-Up Utility1196
Step 3:Putting It All Together—A New Reply Script1199
More on HTML and URL Escapes1201
URL Escape Code Conventions1202
Python HTML and URL Escape Tools1203
Escaping HTML Code1203
Escaping URLs1204
Escaping URLs Embedded in HTML Code1205
Transferring Files to Clients and Servers1209
Displaying Arbitrary Server Files on the Client1211
Uploading Client Files to the Server1218
More Than One Way to Push Bits over the Net1227
16.The PyMailCGI Server1229
"Things to Do When Visiting Chicago"1229
The PyMailCGI Website1230
Implementation Overview1230
New in This Fourth Edition(Version 3.0)1233
New in the Prior Edition(Version 2.0)1235
Presentation Overview1236
Running This Chapter's Examples1237
The Root Page1239
Configuring PyMailCGI1240
Sending Mail by SMTP1241
The Message Composition Page1242
The Send Mail Script1242
Error Pages1246
Common Look-and-Feel1246
Using the Send Mail Script Outside a Browser1247
Reading POP Email1249
The POP Password Page1250
The Mail Selection List Page1251
Passing State Information in URL Link Parameters1254
Security Protocols1257
The Message View Page1259
Passing State Information in HTML Hidden Input Fields1262
Escaping Mail Text and Passwords in HTML1264
Processing Fetched Mail1266
Reply and Forward1267
Delete1268
Deletions and POP Message Numbers1272
Utility Modules1276
External Components and Configuration1276
POP Mail Interface1277
POP Password Encryption1278
Common Utilities Module1286
Web Scripting Trade-Offs1291
PyMailCGI Versus PyMailGUI1292
The Web Versus the Desktop1293
Other Approaches1296
Part Ⅴ.Tools and Techniques1303
17.Databases and Persistence1303
"Give Me an Order of Persistence,but Hold the Pickles"1303
Persistence Options in Python1303
DBM Files1305
Using DBM Files1305
DBM Details:Files,Portability,and Close1308
Pickled Objects1309
Using Object Pickling1310
Pickling in Action1311
Pickle Details:Protocols,Binary Modes,and_pickle1314
Shelve Files1315
Using Shelves1316
Storing Built-in Object Types in Shelves1317
Storing Class Instances in Shelves1318
Changing Classes of Objects Stored in Shelves1320
Shelye Constraints1321
Pickled Class Constraints1323
Other Shelve Limitations1324
The ZODB Object-Oriented Database1325
The Mostly Missing ZODB Tutorial1326
SQL Database Interfaces1329
SOL Interface Overview1330
An SOL Database API Tutorial with SQLite1332
Building Record Dictionaries1339
Tying the Pieces Together1342
Loading Database Tables ffom Files1344
SQL Utility Scripts1347
SQL Resources1354
ORMs:Object Relational Mappers1354
PyForm:A Persistent Object Viewer(External)1356
18.Data Structures1359
"Roses Are Red,Violets Are Blue;Lists Are Mutable,and SoIs Set Foo"1359
Implementing Stacks1360
Built-in Options1360
A Stack Module1362
A Stack Class1364
Customization:Performance Monitors1366
Optimization:Tuple Tree Stacks1367
Optimization:In-Place List Modifications1369
Timing the Improvements1371
Implementing Sets1373
Built-in Options1374
Set Functions1375
Set Classes1377
Optimization:Moving Sets to Dictionaries1378
Adding Relational Algebra to Sets(External)1382
Subclassing Built-in Types1383
Binary Search Trees1385
Built-in Options1385
Implementing Binary Trees1386
Trees with Both Keys and Values1388
Graph Searching1390
Implementing Graph Search1390
Moving Graphs to Classes1393
Permuting Sequences1395
Reversing and Sorting Sequences1397
Implementing Reversals1398
Implementing Sorts1399
Data Structures Versus Built-ins:The Conclusion1400
PyTree:A Generic Tree Object Viewer1402
19.Text and Language1405
“See Jack Hack.Hack,Jack,Hack”1405
Strategies for Processing Text in Python1405
String Method Utilities1406
Templating with Replacements and Formats1408
Parsing with Splits and Joins1409
Summing Columns in a File1410
Parsing and Unparsing Rule Strings1412
Regular Expression Pattern Matching1415
The re Module1416
First Examples1416
String Operations Versus Patterns1418
Using the re Module1421
More Pattern Examples1425
Scanning C Header Files for Patterns1427
XML and HTML Parsing1429
XML Parsing in Action1430
HTML Parsing in Action1435
Advanced Language Tools1438
Custom Language Parsers1440
The Expression Grammar1440
The Parser's Code1441
Adding a Parse Tree Interpreter1449
Parse Tree Structure1454
Exploring Parse Trees with the PyTree GUI1456
Parsers Versus Python1457
PyCalc:A Calculator Program/Object1457
A Simple Calculator GUI1458
PvCalc-A"Real"Calculator GUI1463
20.Python/C Integration1483
"I Am Lost at C"1483
Extending and Embedding1484
Extending Python in C:Overview1486
A Simple C Extension Module1487
The SWIG Integration Code Generator1491
A Simple SWIG Example1491
Wrapping C Environment Calls1495
Adding Wrapper Classes to Flat Libraries1499
Wrapping C Environment Calls with SWIG1500
Wrapping C++ Classes with SWIG1502
A Simple C++ Extension Class1503
Wrapping the C++ Class with SWIG1505
Using the C++ Class in Python1507
Other Extending Tools1511
Embedding Python in C:Overview1514
The C Embedding API1515
What Is Embedded Code?1516
Basic Embedding Techniques1518
Running Simple Code Strings1519
Running Code Strings with Results and Namespaces1522
Calling Python Objects1524
Running Strings in Dictionaries1526
Precompiling Strings to Bytecode1528
Registering Callback Handler Objects1530
Registration Implementation1531
Using Python Classes in C1535
Other Integration Topics1538
Part Ⅵ.The End1543
21.Conclusion:Python and the Development Cycle1543
"That's the End of the Book,Now Here's the Meaning of Life"1544
"Something's Wrong with the Way We Program Computers"1544
The"Gilligan Factor"1544
Doing the Right Thing1545
The Static Language Build Cycle1546
Artificial Complexities1546
One Language Does Not Fit All1546
Enter Python1547
But What About That Bottleneck?1548
Python Provides Immediate Turnaround1549
Python Is"Executable Pseudocode"1550
Python Is OOP Done Right1550
Python Fosters Hybrid Applications1551
On Sinking the Titanic1552
So What's"Python:The Sequel"?1555
In the Final Analysis...1555
Index1557