ImageVerifierCode 换一换
格式:PDF , 页数:1628 ,大小:29.11MB ,
资源ID:3722    下载:注册后免费下载
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.wenkunet.com/d-3722.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录   微博登录 

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Python编程-第4版-Programming.Python.4th.Edition.Mark.Lutz.文字版.pdf)为本站会员(刘岱文)主动上传,文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知文库网(发送邮件至13560552955@163.com或直接QQ联系客服),我们立即给予删除!

Python编程-第4版-Programming.Python.4th.Edition.Mark.Lutz.文字版.pdf

1、Programming PythonFOURTH EDITIONProgramming PythonMark LutzBeijing Cambridge Farnham Kln Sebastopol TokyoProgramming Python, Fourth Editionby Mark LutzCopyright 2011 Mark Lutz. All rights reserved.Printed in the United States of America.Published by OReilly Media, Inc., 1005 Gravenstein Highway Nort

2、h, Sebastopol, CA 95472.OReilly books may be purchased for educational, business, or sales promotional use. Online editionsare also available for most titles (http:/ ). For more information, contact ourcorporate/institutional sales department: (800) 998-9938 or .Editor: Julie SteeleProduction Edito

3、r: Teresa ElseyProofreader: Teresa ElseyIndexer: Lucie HaskinsCover Designer: Karen MontgomeryInterior Designer: David FutatoIllustrator: Robert RomanoPrinting History:October 1996: First Edition. March 2001: Second Edition. August 2006: Third Edition. December 2010: Fourth Edition. Nutshell Handboo

4、k, the Nutshell Handbook logo, and the OReilly logo are registered trademarks ofOReilly Media, Inc. Programming Python, the image of an African rock python, and related trade dressare trademarks of OReilly Media, Inc.Many of the designations used by manufacturers and sellers to distinguish their pro

5、ducts are claimed astrademarks. Where those designations appear in this book, and OReilly Media, Inc., was aware of atrademark claim, the designations have been printed in caps or initial caps.While every precaution has been taken in the preparation of this book, the publisher and author assumeno re

6、sponsibility for errors or omissions, or for damages resulting from the use of the information con-tained herein.ISBN: 978-0-596-15810-1QG1292258056Table of ContentsPreface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7、 . . . xxiiiPart I. The Beginning 1. A Sneak Preview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3“Programming Python: The Short Story” 3The Task 4Step 1: Representing Records 4Using Lists 4Using Dictionaries 9Step 2: Storing Record

8、s Persistently 14Using Formatted Files 14Using Pickle Files 19Using Per-Record Pickle Files 22Using Shelves 23Step 3: Stepping Up to OOP 26Using Classes 27Adding Behavior 29Adding Inheritance 29Refactoring Code 31Adding Persistence 34Other Database Options 36Step 4: Adding Console Interaction 37A Co

9、nsole Shelve Interface 37Step 5: Adding a GUI 40GUI Basics 40Using OOP for GUIs 42Getting Input from a User 44A GUI Shelve Interface 46Step 6: Adding a Web Interface 52CGI Basics 52vDownload from Wow! eBook Running a Web Server 55Using Query Strings and urllib 57Formatting Reply Text 59A Web-Based S

10、helve Interface 60The End of the Demo 69Part II. System Programming 2. System Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73“The os.path to Knowledge” 73Why Python Here? 73The Next Five Chapters 74System Scripting Overview

11、 75Python System Modules 76Module Documentation Sources 77Paging Documentation Strings 78A Custom Paging Script 79String Method Basics 80Other String Concepts in Python 3.X: Unicode and bytes 82File Operation Basics 83Using Programs in Two Ways 84Python Library Manuals 85Commercially Published Refer

12、ences 86Introducing the sys Module 86Platforms and Versions 86The Module Search Path 87The Loaded Modules Table 88Exception Details 89Other sys Module Exports 90Introducing the os Module 90Tools in the os Module 90Administrative Tools 91Portability Constants 92Common os.path Tools 92Running Shell Co

13、mmands from Scripts 94Other os Module Exports 1003. Script Execution Context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103“Id Like to Have an Argument, Please” 103Current Working Directory 104CWD, Files, and Import Paths 104CWD and Command Lines 10

14、6vi | Table of ContentsCommand-Line Arguments 106Parsing Command-Line Arguments 107Shell Environment Variables 109Fetching Shell Variables 110Changing Shell Variables 111Shell Variable Fine Points: Parents, putenv, and getenv 112Standard Streams 113Redirecting Streams to Files and Programs 114Redire

15、cted Streams and User Interaction 119Redirecting Streams to Python Objects 123The io.StringIO and io.BytesIO Utility Classes 126Capturing the stderr Stream 127Redirection Syntax in Print Calls 127Other Redirection Options: os.popen and subprocess Revisited 1284. File and Directory Tools . . . . . .

16、. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135“Erase Your Hard Drive in Five Easy Steps!” 135File Tools 135The File Object Model in Python 3.X 136Using Built-in File Objects 137Binary and Text Files 146Lower-Level File Tools in the os Module 155File Scanners

17、160Directory Tools 163Walking One Directory 164Walking Directory Trees 168Handling Unicode Filenames in 3.X: listdir, walk, glob 1725. Parallel System Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177“Telling the Monkeys What to Do” 177Fork

18、ing Processes 179The fork/exec Combination 182Threads 186The _thread Module 189The threading Module 199The queue Module 204Preview: GUIs and Threads 208More on the Global Interpreter Lock 211Program Exits 213sys Module Exits 214os Module Exits 215Shell Command Exit Status Codes 216Process Exit Statu

19、s and Shared State 219Table of Contents | viiThread Exits and Shared State 220Interprocess Communication 222Anonymous Pipes 224Named Pipes (Fifos) 234Sockets: A First Look 236Signals 240The multiprocessing Module 243Why multiprocessing? 243The Basics: Processes and Locks 245IPC Tools: Pipes, Shared

20、Memory, and Queues 248Starting Independent Programs 254And Much More 256Why multiprocessing? The Conclusion 257Other Ways to Start Programs 258The os.spawn Calls 258The os.startfile call on Windows 261A Portable Program-Launch Framework 263Other System Tools Coverage 2686. Complete System Programs .

21、 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271“The Greps of Wrath” 271A Quick Game of “Find the Biggest Python File” 272Scanning the Standard Library Directory 272Scanning the Standard Library Tree 273Scanning the Module Search Path 274Scanning the Entire

22、Machine 276Printing Unicode Filenames 279Splitting and Joining Files 282Splitting Files Portably 283Joining Files Portably 286Usage Variations 289Generating Redirection Web Pages 292Page Template File 293Page Generator Script 294A Regression Test Script 297Running the Test Driver 299Copying Directory Trees 304Comparing Directory Trees 308Finding Directory Differences 309Finding Tree Differences 311Running the Script 314Verifying Backups 316Reporting Differences and Other Ideas 317viii | Table of Contents

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:文库网官方知乎号:文库网

经营许可证编号: 粤ICP备2021046453号世界地图

文库网官网©版权所有2025营业执照举报