python编程大全

所需积分/C币:45 2019-02-19 09:39:59 28.97MB PDF
收藏 收藏 1
举报

python编程,Python编程(第4版)(Programming.Python.4th.Edit
Programming Python FOURTH EDITION Programming Python Mark lut ORE|LY° Beijing. Cambridge Farnham. Koln. Sebastopol Tokyo Programming Python, Fourth Edition by mark lutz Copyright@ 2011 Mark Lutz. All rights reserved Printed in the United States of america Published by O Reilly Media, Inc, 1005 Gravenstein Highway North, Sebastopol, CA 95472 O'Reilly books may be purchased for educational, business, or sales promotional use. Online editions arealsoavailableformosttitles(http://my.safaribooksonline.com).Formoreinformationcontactour corporate/institutionalsalesdepartment:(800)998-9938orcorporate@oreilly.com Editor: Julie Steele Indexer: Lucie haskins Production Editor Teresa Elsey Cover designer Karen montgomery Proofreader: Teresa Elsey Interior Designer: David Futato Illustrator: Robert ro Printing History: October 1996 First edition March 2001 Second edition August 2006 Third edition December 2010: Fourth edition Nutshell Handbook, the Nutshell Handbook logo, and the O Reilly logo are registered trademarks of O'Reilly Media, Inc. Programming Python, the image of an African rock python, and related trade dress are trademarks of o'reilly media, Inc Many of the designations used by manufacturers and sellers to distinguish their products are claimed as rademarks. Where those designations appear in this book, and O Reilly Media, Inc, was aware of a trademark 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 assume no responsibility for errors or omissions, or for damages resulting from the use of the information con tained herein ISBN:978-0-596-15810-1 LQG 1292258056 Table of contents Preface ...XXⅢ E8兰 Part I. The Beginning 1. A Sneak preview ooo33V兴=038o=品o “ Programming Python: The Short Story?∴ The task Step 1: Representing Records Using Lists 334449 USing Dictionaries Step 2 Storing Records Persistentl 14 Using Formatted Files 14 Using Pickle Files Using Per-Record Pickle Files 22 Using Shelves Step 3 Stepping Up to OOP 26 Using Classes Adding Behavior Adding inheritance 29 Refactoring Code 31 Adding persistence 34 Other Database Options 36 Step 4: Adding Console Interaction 37 A Console shelve Interface 37 Step 5: Adding a guI 40 GuI Basics Using OOP for GUIs 42 Getting input from a User 44 A GUI Shelve Interface 46 Step 6: Adding a Web Interface 52 CGI Basics 52 Running a web server Using Query Strings and urllib Formatting Reply text 59 A Web-Based shelve Interface The End of the demo Part II. System Programming 2. System Tools 73 The os path to knowledge Why Python her 73 The Next Five Chapters System Scripting overview 75 Python System Modules 76 Module documentation sources 77 Paging Documentation Strings A Custom Paging script String method basics Other String Concepts in Python 3. X: Unicode and bytes 82 lle operation basics Using Programs in Two Ways 84 Python library manuals Commercially published References Introducing the sys module Platforms and versions The Module Search path The loaded modules table Exception details 89 Other sys module exports 90 Introducing the os module 90 Tools in the os module AdministratiⅤ e tools Portability Constants 92 Common os path Tools 92 Running Shell Commands from Scripts Other os Module Exports 100 3. Script Execution Context I'd Like to Have an Argument, Please 103 Current Working director 104 CWD, Files, and Import Paths 104 CWD and Command lines 106 I Table of Contents Command-Line Arguments 106 Parsing Command-Line arguments 107 Shell environment variables 109 Fetching Shell variables 110 Changing Shell variables Shell variable Fine Points: Parents, putenv, and getenv 112 Standard streams 113 Redirecting streams to Files and programs 114 Redirected streams and user interaction 119 Redirecting Streams to Python objects 123 The io. Stringlo and io. ByteslO Utility Classes 126 Capturing the stderr stream 127 Redirection Syntax in Print Calls 127 Other Redirection Options: os popen and subprocess revisited 128 4. File and Directory Tools 135 Erase your hard Drive in Five easy steps 135 File tools 135 The File object Model in Pyth othon 3.X 136 USing Built-in File Objects 137 Binary and Text files 146 Lower -Level file tools in the os module 155 File scanners 160 Directory Tools 163 Walking one directory 164 Walking directory trees 168 Handling Unicode Filenames in 3. X: listdir, walk, glob 172 5. Parallel system Tools 177 Telling the Monkeys What to Do 177 Forking processes 179 The fork/exec Combination 182 reads 186 The thread module 189 The threading module 199 The queue module 204 Preview: GUIs and threads 208 More on the global Interpreter Lock 211 Program exits 213 sys Module exits 214 os Module exits 215 Shell command exit status codes 216 Process exit status and shared state 219 Table of contents|ⅶi Thread Exits and Shared State 220 Interprocess Communication 222 Anonymous Pipes 224 Named Pipes(Fifos, 234 Sockets: A First look 236 gnals 240 The multiprocessing module 243 Why multiprocessing? 243 The basics: Processes and locks 245 IPC Tools: Pipes, Shared Memory, and Queues 248 Starting independent programs And much more Why multiprocessing? The Conclusion 257 Other Ways to Start Programs 258 The os. spawn Calls 258 The os startfile call on windows 261 A Portable Program- Launch Framework 263 Other System Tools Coverage 268 6.〔 omplete System Programs………… 271 The greps of wrath” 271 A Quick Game of“ Find the biggest Python File” 272 Scanning the Standard library directory 272 Scanning the Standard Library tree 273 Scanning the Module Search Path 274 Scanning the entire machine 276 Printing Unicode Filenames 279 Splitting and Joining Files 282 Splitting Files portably 283 Joining Files portabl 286 USage Variations 289 Generating Redirection Web Pages 292 Page Template File 293 Page Generator Script 294 A Regression Test Script 297 Running the Test Driver 299 Copying Directory Trees 304 Comparing Directory Trees 308 Finding directory Differences 309 Finding tree Differences 311 Running the Script 314 Verifying Backups 316 Reporting differences and Other ldeas 317 ⅶ ii Table of Contents

...展开详情
试读 127P python编程大全
立即下载 低至0.43元/次 身份认证VIP会员低至7折
抢沙发
一个资源只可评论一次,评论内容不能少于5个字
关注 私信 TA的资源
上传资源赚积分,得勋章
最新推荐
python编程大全 45积分/C币 立即下载
1/127
python编程大全第1页
python编程大全第2页
python编程大全第3页
python编程大全第4页
python编程大全第5页
python编程大全第6页
python编程大全第7页
python编程大全第8页
python编程大全第9页
python编程大全第10页
python编程大全第11页
python编程大全第12页
python编程大全第13页
python编程大全第14页
python编程大全第15页
python编程大全第16页
python编程大全第17页
python编程大全第18页
python编程大全第19页
python编程大全第20页

试读结束, 可继续阅读

45积分/C币 立即下载 >