Python Standard Library, an essential guide for serious Python programmers, delivers accurate, author-tested documentation of all the modules in the Python Standard Library, along with over 300 annotated example scripts using the modules. This version of the book covers all the new modules and related information for Python 2.0, the first major release of Python in four years.
"We'd like to pretend that 'Fredrik' is a role, but even hundreds of volunteers couldn't possibly keep up. No,'Fredrik' is the result of crossing an http server with a spam filter with an emacs whatsit and some other stuff besides."
—Gordon McMillan, June 1998
The Python 2.0 distribution comes with an extensive standard library, comprised of over 200 modules. This book briefly describes each module and provides one or more sample scripts showing how to use it. All in all, this book contains 360 sample scripts.
"Those people who have nothing better to do than post on the Internet all day long are rarely the ones who have the most insights."
—Jakob Nielsen, December 1998
Since I first stumbled upon Python some five years ago, I've spent hundreds of hours answering questions on the comp.lang.python newsgroup. Maybe someone found a module that might be exactly what he wanted, but he couldn't really figure out how to use it. Maybe someone had picked the wrong module for the task. Or maybe someone tried to reinvent the wheel. Often, a short sample script could be much more helpful than a pointer to the reference documentation.
After posting a couple of scripts each week, for a number of years, you end up with a rather large collection of potentially useful scripts. What you'll find in this book are the best parts from over 3,000 newsgroup messages. You'll also find hundreds of new scripts added to make sure every little nook and cranny of standard library has been fully covered.
I've worked hard to make the scripts both understandable and adaptable. I've intentionally kept the annotations as short as possible. If you want more background, there's plenty of reference material shipped with most Python distributions. In this book, the emphasis is on the code.
This book covers the entire standard library, except the (optional) Tkinter user-interface library. There are several reasons for this, mostly related to time, space, and the fact that I'm working on several other Tkinter documentation projects.
Production Details
This book was written in DocBook SGML. I used a variety of tools, including Secret Labs' PythonWorks, Excosoft Documentor, James Clark's Jade DSSSL processor, Norm Walsh's DocBook stylesheets, and a bunch of Python scripts, of course.
Thanks to my referees: Tim Peters, Guido van Rossum, David Ascher, Mark Lutz, and Rael Dornfest, and the PythonWare crew: Matthew Ellis, Håkan Karlsson, and Rune Uhlin.
Unless otherwise noted, all examples run under Python 1.5.2 and Python 2.0. I've tried not to depend on internal details, and I expect most scripts to work with upcoming 2.x versions as well.
The examples have been tested on Windows, Solaris, and Linux. Except for a few scripts that depend on platform-specific modules, the examples should work right out of the box on most other platforms as well. (If you find something that doesn't work as expected, let me know!)
All code is copyrighted. Of course, you're free to use one or more modules in your own programs, just don't forget where you got them.
Most script files are named after the module they're using, followed by the string "-example-" and a unique "serial number." Note that the scripts sometimes appear out of order; it's done this way on purpose, to match the filenames used in an earlier version of this book, (the eff-bot guide to) The Standard Python Library.
"Since the functions in the C runtime library are not part of the Win32 API, we believe the number of applications that will be affected by this bug to be very limited."
—Microsoft, January 1999
1.1 Introduction
Python's standard library covers a wide range of modules. It includes everything from modules that are as much apart of the Python language as the types and statements defined by the language specification, to obscure modules that are probably useful only to a small number of programs.
This chapter describes a number of fundamental standard library modules. Any larger Python program is likely to use most of these modules, either directly or indirectly.
1.1.1 Built-in Functions and Exceptions
The following two modules are even more basic than all other modules combined: the _ _builtin_ _ module, which defines built-in functions (like len, int, and range), and the exceptions module, which defines all built-in exceptions.
Python imports both modules when it starts up, and makes their content available for all programs.
1.1.2 Operating System Interface Modules
There are a number of modules modeled after the POSIX standard API and the standard C library that provide platform-independent interfaces to the underlying operating system.
The modules in this group include os, which provides file and process operations, os.path, which offers a platform-independent way to pull apart and put together filenames, and time, which provides functions to work with dates and times.
To some extent, networking and thread support modules could also belong in this group, but they are not supported by all Python implementations.
1.1.3 Type Support Modules
Several built-in types have support modules in the standard library. The string module implements commonly used string operations, the math module provides math operations and constants, and the cmath module does the same for complex numbers.
1.1.4 Regular Expressions
The re module provides regular expressions support for Python. Regular expressions are string patterns written in a special syntax, which can be used to match strings and extract substrings.
1.1.5 Language Support Modules
sys gives you access to various interpreter variables, such as the module search path, and the interpreter version. operator provides functional equivalents to many built-in operators. copy allows you to copy objects. And finally, gcgives you more control over the garbage collector facilities in Python 2.0.
【下载地址】
链接:https://pan.baidu.com/s/16MppRHeN28d9o8RRqOLXlA
提取码:3r69
相关文章
为了更好地适应新形势,满足读者对大数据分析处理学习的迫切需要,我们推出了《大数据分析 ∶ R基础及应用》一书 ,力求使读者能够从中了解大数据
读完本书后,你将掌握R语言的精华,并能够熟练使用多种工具来解决各种数据科学难题。
网络爬虫是一个自动提取网页的程序,它为搜索引擎从万维网上下载网页,是搜索引擎的重要组成。传统爬虫从一个或若干初始网页的URL开始, 获得初始
通过它,你将学到如何写能处理大量非结构化文本的 Python 程序。你将获得有丰富标注的涵盖语言学各种数据结构的数据集,而且你将学到分析书面
本书可以作为Python编程语言的一本指南或者教程。它主要是为新手而设计,不过对于有经验的程序员来说,它同样有用。
本书以机器学习与计算统计为主题背景,专门讲t述如何挖掘和分析 Web,上的数据和资源,如何分析用户体验、市场营销、个人品味等诸多信息,并得出
为了能让更多的编程小自轻松地入门编程,我把高效学习法结合 Pvthon 中的核心知识,写成了这本书。随意翻上几页,你就会发现这本书和其他编程
本书结构非常简单,其实就是 52 个习题。其中 26 个覆盖了输入输出、变量、以及函数三个课题,另外 26个覆盖了一些比较高级的话题,如条件
本书以CPython为研究对象,在C代码一级,深入细致地剖析了Python的实现。本书不仅包括了对大量Python内置对象的剖析,更将大量的
本书是学习Python编程语言的入门书籍。Python是一种很流行的开源编程语言,可以在各种领域中用于编写独立的程序和脚本。Python免费
本书用 Python 语言来讲解算法的分析和设计。本书主要关注经典的算法,但同时会为读者理解基本算法问题和解决问题打下很好的基础。全书共 1
本书面向的读者是那些经常使用电子表格软件进行数据处理,但从未写过一行代码的人。前几章会教你设置 Python 运行环境,告诉你计算机是如何看
神经网络是一种模拟人脑的神经网络,以期能够实现类人工智能的机器学习技术。本书揭示神经网络背后的概念,并介绍如何通过Pvthon实现神经网络。
Python 是一种容易学习的强大的编程语言。它包含了高效的高级数据结构,能够用简单而高效的方式进行面向对象编程。Python 优雅的语法和
本书是面向 Python 初学者的学习指南,详细介绍了 Python 编程基础,以及一些高级概念,如面向对象编程。
FlashFXP绿色版网盘下载,附激活教程 1553
FlashFxp百度网盘下载链接:https://pan.baidu.com/s/1MBQ5gkZY1TCFY8A7fnZCfQ。FlashFxp是功能强大的FTP工具
Adobe Fireworks CS6 Ansifa绿色精简版网盘下载 1363
firework可以制作精美或是可以闪瞎眼的gif,这在广告领域是需要常用的,还有firework制作下logo,一些原创的图片还是很便捷的,而且fireworks用法简单,配合dw在做网站这一块往往会发挥出很强大的效果。百度网盘下载链接:https://pan.baidu.com/s/1fzIZszfy8VX6VzQBM_bdZQ
navicat for mysql中文绿色版网盘下载 1441
Navicat for Mysql是用于Mysql数据库管理的一款图形化管理软件,非常的便捷和好用,可以方便的增删改查数据库、数据表、字段、支持mysql命令,视图等等。百度网盘下载链接:https://pan.baidu.com/s/1T_tlgxzdQLtDr9TzptoWQw 提取码:y2yq
火车头采集器(旗舰版)绿色版网盘下载 1621
火车头采集器是站长常用的工具,相比于八爪鱼,简洁好用,易于配置。火车头能够轻松的抓取网页内容,并通过自带的工具对内容进行处理。站长圈想要做网站,火车头采集器是必不可少的。百度网盘链接:https://pan.baidu.com/s/1u8wUqS901HgOmucMBBOvEA
Photoshop(CS-2015-2023)绿色中文版软件下载 1748
安装文件清单(共46G)包含Window和Mac OS各个版本的安装包,从cs到cc,从绿色版到破解版,从安装文件激活工具,应有尽有,一次性打包。 Photoshop CC绿色精简版 Photoshop CS6 Mac版 Photoshop CC 2015 32位 Photoshop CC 2015 64位 Photoshop CC 2015 MAC版 Photoshop CC 2017 64位 Adobe Photoshop CC 2018 Adobe_Photoshop_CC_2018 Photoshop CC 2018 Win32 Photoshop CC 2018 Win64