python 模块大全
Python 模块大全(很详细!)
- 标签:
- Python /
- 模块 /
- 教程 /
- 4479
- 编辑
- 删除
- Python 模块大全很详细
- 01 关于本书
- 02 代码约定
- 03 关于例子
- 04 如何联系我们
- 1 核心模块
- 11 介绍
- 111 内建函数和异常
- 112 操作系统接口模块
- 113 类型支持模块
- 114 正则表达式
- 115 语言支持模块
- 12 _ _builtin_ _ 模块
- 121 使用元组或字典中的参数调用函数
- 1211 Example 1-1 使用 apply 函数
- 1212 Example 1-2 使用 apply 函数传递关键字参数
- 1213 Example 1-3 使用 apply 函数调用基类的构造函数
- 122 加载和重载模块
- 1221 Example 1-4 使用 _ _import_ _ 函数加载模块
- 1222 Example 1-5 Plug-in 例子
- 1223 Example 1-6 使用 _ _import_ _ 函数获得特定函数
- 1224 Example 1-7 使用 _ _import_ _ 函数实现 延迟导入
- 1225 Example 1-8 使用 reload 函数
- 123 关于名称空间
- 1231 Example 1-9 使用 dir 函数
- 1232 Example 1-10 使用 dir 函数查找类的所有成员
- 1233 Example 1-11 使用 vars 函数
- 124 检查对象类型
- 1241 Example 1-12 使用 type 函数
- 1242 Example 1-13 对文件名和文件对象使用 type 函数
- 1243 Example 1-14 使用 callable 函数
- 1244 Example 1-15 使用 isinstance 函数
- 1245 Example 1-16 使用 issubclass 函数
- 125 计算 Python 表达式
- 1251 Example 1-17 使用 eval 函数
- 1252 Example 1-18 使用 eval 函数执行任意命令
- 1253 Example 1-19 安全地使用 eval 函数求值
- 126 编译和执行代码
- 1261 Example 1-20 使用 compile 函数检查语法
- 1262 Example 1-21 执行已编译的代码
- 1263 Example 1-22 简单的代码生成工具
- 1264 Example 1-23 使用 execfile 函数
- 1265 Example 1-24 hellopy 脚本
- 127 从 _ _builtin_ _ 模块重载函数
- 1271 Example 1-25 显式地访问 _ _builtin_ _ 模块中的函数
- 121 使用元组或字典中的参数调用函数
- 13 exceptions 模块
- 1301 Example 1-26 使用 exceptions 模块
- 14 os 模块
- 141 处理文件
- 1411 Example 1-27 使用 os 模块重命名和删除文件
- 142 处理目录
- 1421 Example 1-28 使用 os 列出目录下的文件
- 1422 Example 1-29 使用 os 模块改变当前工作目录
- 1423 Example 1-30 使用 os 模块创建删除多个目录级
- 1424 Example 1-31 使用 os 模块创建删除目录
- 143 处理文件属性
- 1431 Example 1-32 使用 os 模块获取文件属性
- 1432 Example 1-33 使用 os 模块修改文件的权限和时间戳
- 144 处理进程
- 1441 Example 1-34 使用 os 执行操作系统命令
- 1442 Example 1-35 使用 os 模块启动新进程
- 1443 Example 1-36 使用 os 模块调用其他程序 Unix
- 1444 Example 1-37 使用 os 模块调用其他程序 Windows
- 1445 Example 1-38 使用 os 模块在后台执行程序 Windows
- 1446 Example 1-39 使用 spawn 或 forkexec 调用其他程序
- 145 处理守护进程Daemon Processes
- 1451 Example 1-40 使用 os 模块使脚本作为守护执行 Unix
- 1452 Example 1-41 使用 os 模块终止当前进程
- 141 处理文件
- 15 ospath 模块
- 151 处理文件名
- 1511 Example 1-42 使用 ospath 模块处理文件名
- 1512 Example 1-43 使用 ospath 模块检查文件名的特征
- 1513 Example 1-44 使用 ospath 模块将用户名插入到文件名
- 1514 Example 1-45 使用 ospath 替换文件名中的环境变量
- 152 搜索文件系统
- 1521 Example 1-46 使用 ospath 搜索文件系统
- 1522 Example 1-47 使用 oslistdir 搜索文件系统
- 1523 Example 1-48 使用 DirectoryWalker 搜索文件系统
- 1524 Example 1-49 使用 DirectoryStatWalker 搜索文件系统
- 151 处理文件名
- 16 stat 模块
- 1601 Example 1-50 Using the stat Module
- 17 string 模块
- 1701 Example 1-51 使用 string 模块
- 1702 Example 1-52 使用字符串方法替代 string 模块函数
- 1703 Example 1-53 使用 string 模块将字符串转为数字
- 18 re 模块
- 1801 Example 1-54 使用 re 模块来匹配字符串
- 1802 Example 1-55 使用 re 模块抽出匹配的子字符串
- 1803 Example 1-56 使用 re 模块搜索子字符串
- 1804 Example 1-57 使用 re 模块替换子字符串
- 1805 Example 1-58 使用 re 模块替换字符串通过回调函数
- 1806 Example 1-59 使用 re 模块匹配多个模式中的一个
- 19 math 模块
- 1901 Example 1-60 使用 math 模块
- 110 cmath 模块
- 11001 Example 1-61 使用 cmath 模块
- 111 operator 模块
- 11101 Example 1-62 使用 operator 模块
- 11102 Example 1-63 使用 operator 模块检查类型
- 112 copy 模块
- 11201 Example 1-64 使用 copy 模块复制对象
- 11202 Example 1-65 使用 copy 模块复制集合Collections
- 113 sys 模块
- 1131 处理命令行参数
- 11311 Example 1-66 使用sys模块获得脚本的参数
- 1132 处理模块
- 11321 Example 1-67 使用sys模块操作模块搜索路径
- 11322 Example 1-68 使用sys模块查找内建模块
- 11323 Example 1-69 使用sys模块查找已导入的模块
- 1133 处理引用记数
- 11331 Example 1-70 使用sys模块获得引用记数
- 11332 Example 1-71 使用sys模块获得当前平台
- 1134 跟踪程序
- 11341 Example 1-72 使用sys模块配置分析函数
- 11342 Example 1-73 使用sys模块配置单步跟踪函数
- 1135 处理标准输出输入
- 11351 Example 1-74 使用sys重定向输出
- 1136 退出程序
- 11361 Example 1-75 使用sys模块退出程序
- 11362 Example 1-76 捕获sysexit调用
- 11363 Example 1-77 另一种捕获sysexit调用的方法
- 1131 处理命令行参数
- 114 atexit 模块
- 11401 Example 1-78 使用 atexit 模块
- 115 time 模块
- 1151 获得当前时间
- 11511 Example 1-79 使用 time 模块获取当前时间
- 1152 将时间值转换为字符串
- 11521 Example 1-80 使用 time 模块格式化时间输出
- 1153 将字符串转换为时间对象
- 11531 Example 1-81 使用 timestrptime 函数解析时间
- 11532 Example 1-82 strptime 实现
- 1154 转换时间值
- 11541 Example 1-83 使用 time 模块将本地时间元组转换为时间值整数
- 11542 Example 1-84 将 UTC 时间元组转换为时间值整数
- 1155 Timing 相关
- 11551 Example 1-85 使用 time 模块评价算法
- 1151 获得当前时间
- 116 types 模块
- 11601 Example 1-86 使用 types 模块
- 117 gc 模块
- 11701 Example 1-87 使用 gc 模块收集循环引用垃圾
- 11 介绍
- 2 更多标准模块
- 21 概览
- 211 文件与流
- 212 类型封装
- 213 随机数字
- 214 加密算法
- 22 fileinput 模块
- 2201 Example 2-1 使用 fileinput 模块循环一个文本文件
- 2202 Example 2-2 使用 fileinput 模块处理多个文本文件
- 2203 Example 2-3 使用 fileinput 模块将 CRLF 改为 LF
- 23 shutil 模块
- 2301 Example 2-4 使用 shutil 复制文件
- 2302 Example 2-5 使用 shutil 模块复制删除目录树
- 24 tempfile 模块
- 2401 Example 2-6 使用 tempfile 模块创建临时文件
- 2402 Example 2-7 使用 tempfile 模块打开临时文件
- 25 StringIO 模块
- 2501 Example 2-8 使用 StringIO 模块从内存文件读入内容
- 2502 Example 2-9 使用 StringIO 模块向内存文件写入内容
- 2503 Example 2-10 使用 StringIO 模块捕获输出
- 26 cStringIO 模块
- 2601 Example 2-11 使用 cStringIO 模块
- 2602 Example 2-12 后退至 StringIO
- 27 mmap 模块
- 2701 Example 2-13 使用 mmap 模块
- 2702 Example 2-14 对映射区域使用字符串方法和正则表达式
- 28 UserDict 模块
- 2801 Example 2-15 使用 UserDict 模块
- 29 UserList 模块
- 2901 Example 2-16 使用 UserList 模块
- 210 UserString 模块
- 21001 Example 2-17 使用 UserString 模块
- 211 traceback 模块
- 21101 Example 2-18 使用 traceback 模块打印跟踪返回信息
- 21102 Example 2-19 使用 traceback 模块将跟踪返回信息复制到字符串
- 21103 Example 2-20 使用 traceback Module 模块编码 Traceback 对象
- 212 errno 模块
- 21201 Example 2-21 使用 errno 模块
- 21202 Example 2-22 使用 errorcode 字典
- 213 getopt 模块
- 21301 Example 2-23 使用 getopt 模块
- 21302 Example 2-24 使用 getopt 模块处理长选项
- 214 getpass 模块
- 21401 Example 2-25 使用 getpass 模块
- 215 glob 模块
- 21501 Example 2-26 使用 glob 模块
- 216 fnmatch 模块
- 21601 Example 2-27 使用 fnmatch 模块匹配文件
- 21602 Example 2-28 使用 fnmatch 模块将模式转换为正则表达式
- 217 random 模块
- 21701 Example 2-29 使用 random 模块获得随机数字
- 21702 Example 2-30 使用 random 模块从序列取出随机项
- 21703 Example 2-31 使用 random 模块打乱一副牌
- 21704 Example 2-32 使用 random 模块生成高斯分布随机数
- 218 whrandom 模块
- 21801 Example 2-33 使用 whrandom 模块
- 21802 Example 2-34 使用 whrandom 模块创建多个随机生成器
- 219 md5 模块
- 21901 Example 2-35 使用 md5 模块
- 21902 Example 2-36 使用 md5 模块获得十六进制或 base64 编码的 md5 值
- 21903 Example 2-37 使用 md5 模块来处理口令的发送与应答的验证
- 21904 Example 2-38 使用 md5 模块检查数据完整性
- 220 sha 模块
- 22001 Example 2-39 使用 sha 模块
- 221 crypt 模块
- 22101 Example 2-40 使用 crypt 模块
- 22102 Example 2-41 使用 crypt 模块身份验证
- 222 rotor 模块
- 22201 Example 2-42 使用 rotor 模块
- 223 zlib 模块
- 22301 Example 2-43 使用 zlib 模块压缩字符串
- 22302 Example 2-44 使用 zlib 模块压缩多个不同类型文件
- 22303 Example 2-45 使用 zlib 模块解压缩流
- 22304 Example 2-46 压缩流的仿文件访问方式
- 224 code 模块
- 22401 Example 2-47 使用 code 模块编译语句
- 22402 Example 2-48 使用 code 模块模拟交互解释器
- 22403 Example 2-49 使用 code 模块实现简单的 Debugging
- 21 概览
- 3 线程和进程
- 31 概览
- 311 线程
- 312 进程
- 32 threading 模块
- 3201 Example 3-1 使用 threading 模块
- 33 Queue 模块
- 3301 Example 3-2 使用 Queue 模块
- 3302 Example 3-3 使用限制大小的 Queue 模块
- 3303 Example 3-4 使用 Queue 模块实现优先级队列
- 3304 Example 3-5 使用 Queue 模块实现一个堆栈
- 34 thread 模块
- 3401 Example 3-6 使用 thread 模块
- 35 commands 模块
- 3501 Example 3-7 使用 commands 模块
- 36 pipes 模块
- 3601 Example 3-8 使用 pipes 模块
- 37 popen2 模块
- 3701 Example 3-9 使用 popen2 模块对字符串排序Module to Sort Strings
- 3702 Example 3-10 使用 popen2 模块控制 gnuchess
- 38 signal 模块
- 3801 Example 3-11 使用 signal 模块
- 31 概览
- 4 数据表示
- 41 概览
- 411 二进制数据
- 412 自描述格式
- 413 输出格式
- 414 编码二进制数据
- 42 array 模块
- 4201 Example 4-1 使用 array 模块将数列转换为字符串
- 4202 Example 4-2 作为普通序列操作阵列
- 4203 Example 4-3 使用阵列将字符串转换为整数列表
- 4204 Example 4-4 使用 array 模块判断平台字节序
- 4205 Example 4-5 使用 sysbyteorder 属性判断平台字节序 Python 20 及以后
- 43 struct 模块
- 4301 Example 4-6 使用 struct 模块
- 44 xdrlib 模块
- 4401 Example 4-7 使用 xdrlib 模块
- 4402 Example 4-8 使用 xdrlib 模块发送 RPC 调用包
- 45 marshal 模块
- 4501 Example 4-9 使用 marshal 模块组合不连续数据
- 4502 Example 4-10 使用 marshal 模块处理代码
- 46 pickle 模块
- 4601 Example 4-11 使用 pickle 模块
- 4602 Example 4-12 使用 pickle 模块的二进制模式
- 47 cPickle 模块
- 4701 Example 4-13 使用 cPickle 模块
- 48 copy_reg 模块
- 4801 Example 4-14 使用 copy_reg 模块实现 code 对象的 pickle 操作
- 4802 Example 4-15 使用 copy_reg 模块实现文件对象的 pickle 操作
- 49 pprint 模块
- 4901 Example 4-16 使用 pprint 模块
- 410 repr 模块
- 41001 Example 4-17 使用 repr 模块
- 411 base64 模块
- 41101 Example 4-18 使用 base64 模块编码文件
- 41102 Example 4-19 使用 base64 模块编码字符串
- 41103 Example 4-20 使用 base64 模块做基本验证
- 41104 Example 4-21 使用 base64 为 Tkinter 封装 GIF 格式
- 412 binhex 模块
- 41201 Example 4-22 使用 binhex 模块
- 413 quopri 模块
- 41301 Example 4-23 使用 quopri 模块
- 414 uu 模块
- 41401 Example 4-24 使用 uu 模块编码二进制文件
- 41402 Example 4-25 使用 uu 模块解码 uu 格式的文件
- 415 binascii 模块
- 41501 Example 4-26 使用 binascii 模块
- 41 概览
- 5 文件格式
- 51 概览
- 511 Markup 语言
- 512 配置文件
- 513 压缩档案格式
- 52 xmllib 模块
- 5201 Example 5-1 使用 xmllib 模块获取元素的信息
- 5202 Example 5-2 使用 xmllib 模块
- 53 xmlparsersexpat 模块
- 5301 Example 5-3 使用 xmlparsersexpat 模块
- 5302 Example 5-4 使用 xmlparsersexpat 模块读取 ISO Latin-1 文本
- 54 sgmllib 模块
- 5401 Example 5-5 使用 sgmllib 模块提取 Title 元素
- 5402 Example 5-6 使用 sgmllib 模块格式化 SGML 文档
- 5403 Example 5-7 使用 sgmllib 模块检查格式
- 5404 Example 5-8 使用 sgmllib 模块过滤 SGML 文档
- 55 htmllib 模块
- 5501 Example 5-9 使用 htmllib 模块
- 56 htmlentitydefs 模块
- 5601 Example 5-10 使用 htmlentitydefs 模块
- 5602 Example 5-11 使用 htmlentitydefs 模块翻译实体
- 5603 Example 5-12 转义 ISO Latin-1 实体
- 57 formatter 模块
- 5701 Example 5-13 使用 formatter 模块将 HTML 转换为事件流
- 5702 Example 5-14 使用 formatter 模块将 HTML 转换为纯文本
- 5703 Example 5-15 使用 formatter 模块自定义 Writer
- 58 ConfigParser 模块
- 5801 Example 5-16 使用 ConfigParser 模块
- 5802 Example 5-17 使用 ConfigParser 模块写入配置数据
- 59 netrc 模块
- 5901 Example 5-18 使用 netrc 模块
- 510 shlex 模块
- 51001 Example 5-19 使用 shlex 模块
- 511 zipfile 模块
- 5111 列出内容
- 51111 Example 5-20 使用 zipfile 模块列出 ZIP 文档中的文件
- 5112 从 ZIP 文件中读取数据
- 51121 Example 5-21 使用 zipfile 模块从 ZIP 文件中读取数据
- 5113 向 ZIP 文件写入数据
- 51131 Example 5-22 使用 zipfile 模块将文件储存在 ZIP 文件里
- 51132 Example 5-23 使用 zipfile 模块在 ZIP 文件中储存字符串
- 5111 列出内容
- 512 gzip 模块
- 51201 Example 5-24 使用 gzip 模块读取压缩文件
- 51202 Example 5-25 给 gzip 模块添加 seektell 支持
- 51 概览
- 6 邮件和新闻消息处理
- 61 概览
- 62 rfc822 模块
- 6201 Example 6-1 使用 rfc822 模块
- 6202 Example 6-2 使用 rfc822 模块解析标头字段
- 63 mimetools 模块
- 6301 Example 6-3 使用 mimetools 模块
- 64 MimeWriter 模块
- 6401 Example 6-4 使用 MimeWriter 模块
- 6402 Example 6-5 MimeWriter 模块的辅助类
- 65 mailbox 模块
- 6501 Example 6-6 使用 mailbox 模块
- 66 mailcap 模块
- 6601 Example 6-7 使用 mailcap 模块获得 Capability 字典
- 6602 Example 6-8 使用 mailcap 模块获得打开
- 67 mimetypes 模块
- 6701 Example 6-9 使用 mimetypes 模块
- 68 packmail 模块
- 6801 Example 6-10 使用 packmail 打包单个文件
- 69 mimify 模块
- 6901 Example 6-12 使用 mimify 模块解码信息
- 6902 Example 6-13 使用 mimify 模块编码信息
- 610 multifile 模块
- 61001 Example 6-14 使用 multifile 模块
- 7 网络协议
- 71 概览
- 711 Internet 时间协议
- 712 HTTP 协议
- 72 socket 模块
- 7201 Example 7-1 使用 socket 模块实现一个时间客户端
- 7202 Example 7-2 使用 socket 模块实现一个时间服务器
- 7203 Example 7-3 一个时间协议客户端
- 7204 Example 7-4 使用 socket 模块实现一个报文时间客户端
- 73 select 模块
- 7301 Example 7-6 使用 select 模块等待经 socket 发送的数据
- 74 asyncore 模块
- 7401 Example 7-7 使用 asyncore 模块从时间服务器获得时间
- 7402 Example 7-8 使用 asyncore 模块实现时间服务器
- 7403 Example 7-9 使用 asyncore 模块发送 HTTP 请求
- 7404 Example 7-10 使用 SimpleAsyncHTTP 类
- 7405 Example 7-11 使用 SimpleAsyncHTTP 类处理重定向
- 75 asynchat 模块
- 7501 Example 7-12 使用 asynchat 模块实现一个迷你 HTTP 服务器
- 7502 Example 7-13 使用 asynchat 模块实现一个简单的 HTTP 服务器
- 76 urllib 模块
- 7601 Example 7-14 使用 urllib 模块获取远程资源
- 7602 Example 7-15 用 urllib 模块实现自动身份验证
- 77 urlparse 模块
- 7701 Example 7-16 使用 urlparse 模块
- 7702 Example 7-17 使用 urlparse 模块处理 HTTP 定位器 HTTP Locators
- 7703 Example 7-18 使用 urlparse 模块处理 HTTP 定位器 HTTP Locators
- 7704 Example 7-19 使用 urlparse 模块组合相对定位器
- 78 cookie 模块
- 7801 Example 7-20 使用 cookie 模块
- 79 robotparser 模块
- 7901 Example 7-21 使用 robotparser 模块
- 710 ftplib 模块
- 71001 Example 7-22 使用 ftplib 模块获得目录列表
- 71002 Example 7-23 使用 ftplib 模块下载文件
- 71003 Example 7-24 使用 ftplib 模块上传文件
- 711 gopherlib 模块
- 71101 Example 7-25 使用 gopherlib 模块
- 712 httplib 模块
- 71201 Example 7-26 使用 httplib 模块
- 7121 将数据发送给服务器
- 71211 Example 7-27 使用 httplib 发送数据
- 713 poplib 模块
- 71301 Example 7-28 使用 poplib 模块
- 714 imaplib 模块
- 71401 Example 7-29 使用 imaplib 模块
- 715 smtplib 模块
- 71501 Example 7-30 使用 smtplib 模块
- 716 telnetlib 模块
- 71601 Example 7-31 使用 telnetlib 模块登陆到远程服务器
- 717 nntplib 模块
- 7171 列出消息
- 71711 Example 7-32 使用 nntplib 模块列出消息
- 7172 下载消息
- 71721 Example 7-33 使用 nntplib 模块下载消息
- 71722 Example 7-34 使用 nntplib 和 rfc822 模块处理消息
- 7171 列出消息
- 718 SocketServer 模块
- 71801 Example 7-35 使用 SocketServer 模块
- 719 BaseHTTPServer 模块
- 71901 Example 7-36 使用 BaseHTTPServer 模块
- 720 SimpleHTTPServer 模块
- 72001 Example 7-37 使用 SimpleHTTPServer 模块
- 72002 Example 7-38 使用 SimpleHTTPServer 模块实现代理
- 721 CGIHTTPServer 模块
- 72101 Example 7-39 使用 CGIHTTPServer 模块
- 722 cgi 模块
- 72201 Example 7-40 使用 cgi 模块
- 723 webbrowser 模块
- 72301 Example 7-41 使用 webbrowser 模块
- 71 概览
- 8 国际化
- 81 locale 模块
- 8101 Example 8-2 使用 locale 模块获得当前平台 locale 设置
- 82 unicodedata 模块
- 8201 Example 8-3 使用 unicodedata 模块
- 83 ucnhash 模块
- 8301 Example 8-4 使用 ucnhash 模块
- 81 locale 模块
- 9 多媒体相关模块
- 91 概览
- 92 imghdr 模块
- 9201 Example 9-1 使用 imghdr 模块
- 93 sndhdr 模块
- 9301 Example 9-2 使用 sndhdr 模块
- 94 whatsound 模块
- 9401 Example 9-3 使用 whatsound 模块
- 95 aifc 模块
- 9501 Example 9-4 使用 aifc 模块
- 96 sunau 模块
- 9601 Example 9-5 使用 sunau 模块
- 97 sunaudio 模块
- 9701 Example 9-6 使用 sunaudio 模块
- 98 wave 模块
- 9801 Example 9-7 使用 wave 模块
- 99 audiodev 模块
- 9901 Example 9-8 使用 audiodev 模块
- 910 winsound 模块
- 91001 Example 9-9 使用 winsound 模块
- 10 数据储存
- 101 概览
- 102 anydbm 模块
- 10201 Example 10-1 使用 anydbm 模块
- 103 whichdb 模块
- 10301 Example 10-2 使用 whichdb 模块
- 104 shelve 模块
- 10401 Example 10-3 使用 shelve 模块
- 10402 Example 10-4 使用 shelve 模块处理给定数据库
- 105 dbhash 模块
- 10501 Example 10-5 使用 dbhash 模块
- 106 dbm 模块
- 10601 Example 10-6 使用 dbm 模块
- 107 dumbdbm 模块
- 10701 Example 10-7 使用 dumbdbm 模块
- 108 gdbm 模块
- 10801 Example 10-8 使用 gdbm 模块
- 11 工具和实用程序
- 111 dis 模块
- 11101 Example 11-1 使用 dis 模块
- 112 pdb 模块
- 11201 Example 11-2 使用 pdb 模块
- 113 bdb 模块
- 11301 Example 11-3 使用 bdb 模块
- 114 profile 模块
- 11401 Example 11-4 U使用 profile 模块
- 115 pstats 模块
- 11501 Example 11-5 使用 pstats 模块
- 116 tabnanny 模块
- 11601 Example 11-6 使用 tabnanny 模块
- 111 dis 模块
- 12 其他模块
- 121 概览
- 122 fcntl 模块
- 12201 Example 12-1 Using the fcntl Module
- 123 pwd 模块
- 12301 Example 12-2 使用 pwd 模块
- 12302 Example 12-3 使用 pwd 模块
- 124 grp 模块
- 12401 Example 12-4 使用 grp 模块
- 12402 Example 12-5 使用 grp 模块缓存用户组信息
- 125 nis 模块
- 12501 Example 12-6 nis
- 126 curses 模块
- 12601 Example 12-7 curses
- 127 termios 模块
- 12701 Example 12-8 使用 termios 模块
- 128 tty 模块
- 12801 Example 12-9 使用 tty 模块
- 129 resource 模块
- 12901 Example 12-10 使用 resource 模块查询当前设置
- 12902 Example 12-11 使用 resource 模块限制资源
- 1210 syslog 模块
- 121001 Example 12-12 使用 syslog 模块
- 1211 msvcrt 模块
- 121101 Example 12-13 使用 msvcrt 模块获得按键值
- 121102 Example 12-14 使用 msvcrt 模块接受键盘输入
- 121103 Example 12-15 使用 msvcrt 模块锁定文件
- 1212 nt 模块
- 121201 Example 12-16 使用 nt 模块
- 1213 _winreg 模块
- 121301 Example 12-17 使用 _winreg 模块
- 1214 posix 模块
- 121401 Example 12-18 使用 posix 模块
- 13 执行支持模块
- 131 dospath 模块
- 13101 Example 13-1 使用 dospath 模块
- 132 macpath 模块
- 13201 Example 13-2 使用 macpath 模块
- 133 ntpath 模块
- 13301 Example 13-3 使用 ntpath 模块
- 134 posixpath 模块
- 13401 Example 13-4 使用 posixpath 模块
- 135 strop 模块
- 13501 Example 13-5 使用 strop 模块
- 136 imp 模块
- 13601 Example 13-6 使用 imp 模块
- 137 new 模块
- 13701 Example 13-7 使用 new 模块
- 138 pre 模块
- 13801 Example 13-8 使用 pre 模块
- 139 sre 模块
- 13901 Example 13-9 使用 sre 模块
- 1310 py_compile 模块
- 131001 Example 13-10 使用 py_compile 模块
- 1311 compileall 模块
- 131101 Example 13-11 使用 compileall 模块编译目录中的所有脚本
- 1312 ihooks 模块
- 131201 Example 13-12 使用 ihooks 模块
- 1313 linecache 模块
- 131301 Example 13-13 使用 linecache 模块
- 1314 macurl2path 模块
- 131401 Example 13-14 使用 macurl2path 模块
- 1315 nturl2path 模块
- 131501 Example 13-15 使用 nturl2path 模块
- 131502 Example 13-16 通过 urllib 调用 nturl2path 模块
- 1316 tokenize 模块
- 131601 Example 13-17 使用 tokenize 模块
- 1317 keyword 模块
- 131701 Example 13-18 使用 keyword 模块
- 1318 parser 模块
- 131801 Example 13-19 使用 parser 模块
- 1319 symbol 模块
- 131901 Example 13-20 使用 symbol 模块
- 1320 token 模块
- 132001 Example 13-21 使用 token 模块
- 131 dospath 模块
- 14 其他模块
- 141 概览
- 142 pyclbr 模块
- 14201 Example 14-1 使用 pyclbr 模块
- 14202 Example 14-2 使用 pyclbr 模块读取类和函数
- 14203 Example 14-3 使用 pyclbr 模块
- 143 filecmp 模块
- 14301 Example 14-4 使用 filecmp 模块
- 144 cmd 模块
- 14401 Example 14-5 使用 cmd 模块
- 145 rexec 模块
- 14501 Example 14-6 使用 rexec 模块
- 146 Bastion 模块
- 14601 Example 14-7 使用 Bastion 模块
- 14602 Example 14-8 使用 Bastion 模块处理非标准过滤器
- 147 readline 模块
- 14701 Example 14-9 使用 readline 模块
- 148 rlcompleter 模块
- 14801 Example 14-10 使用 rlcompleter 模块展开名字
- 149 statvfs 模块
- 14901 Example 14-11 使用 statvfs 模块
- 1410 calendar 模块
- 141001 Example 14-12 使用 calendar 模块
- 141002 Example 14-13 使用 calendar 模块
- 1411 sched 模块
- 141101 Example 14-14 使用 sched 模块
- 1412 statcache 模块
- 141201 Example 14-15 使用 statcache 模块
- 1413 grep 模块
- 141301 Example 14-16 使用 grep 模块
- 1414 dircache 模块
- 141401 Example 14-17 使用 dircache 模块
- 1415 dircmp 模块
- 141501 Example 14-18 使用 dircmp 模块
- 1416 cmp 模块
- 141601 Example 14-19 使用 cmp 模块
- 1417 cmpcache 模块
- 141701 Example 14-20 使用 cmpcache 模块
- 1418 util 模块
- 141801 Example 14-21 实现 util 模块的 remove 函数
- 141802 Example 14-22 实现 util 模块的 readfile 函数
- 141803 Example 14-23 实现 util 模块的 readopenfile 函数
- 1419 soundex 模块
- 141901 Example 14-24 使用 soundex 模块
- 1420 timing 模块
- 142001 Example 14-25 使用 timing 模块
- 142002 Example 14-26 模拟 timing 模块
- 1421 posixfile 模块
- 142101 Example 14-27 使用 posixfile 模块
- 1422 bisect 模块
- 142201 Example 14-28 使用 bisect 模块向列表插入条目
- 142202 Example 14-29 使用 bisect 模块获得插入点位置
- 1423 knee 模块
- 142301 Example 14-30 使用 knee 模块
- 1424 tzparse 模块
- 142401 Example 14-31 使用 tzparse 模块
- 1425 regex 模块
- 142501 Example 14-32 使用 regex 模块
- 1426 regsub 模块
- 142601 Example 14-33 使用 regsub 模块
- 1427 reconvert 模块
- 142701 Example 14-34 使用 reconvert 模块
- 1428 regex_syntax 模块
- 142801 Example 14-35 使用 regex_syntax 模块
- 1429 find 模块
- 142901 Example 14-36 使用 find 模块
- 15 Py 20 后新增模块
- 16 后记
“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
Python 2.0发布附带了一个包含200个以上模块的可扩展的标准库. 本书简要地介绍每个模块并提供至少一个例子来说明如何使用它. 本书一共包含360个例子.
0.1. 关于本书
本书是超过3,000个新闻组讨论的精华部分, 当然也有很多的新脚本, 为了涵盖标准库的每个角落.
我尽力使得每个脚本都易于理解, 易于重用代码. 我有意缩短注释的长度, 如果你想更深入地 了解背景, 那么你可以参阅每个 Python 发布中的参考手册. 本书的重要之处在于范例代码.
我们欢迎任何评论, 建议, 以及 bug 报告, 请将它们发送到 fredrik@pythonware.com. 我将阅读尽我所能阅读所有的邮件, 但可能回复不是那么及时.
本书的相关更新内容以及其他信息请访问 http://www.pythonware.com/people/fredrik/librarybook.htm
关于这些书的信息, 请访问 http://www.pythonware.com/people/fredrik/tkinterbook.htm. (不用看了,又一404)
0.2. 代码约定
0.3. 关于例子
除非提到,所有例子都可以在 Python 1.5.2 和 Python 2.0 下运行. 能不能在 Python 2.4/2.5 下执行…..看参与翻译各位的了.
除了一些平台相关模块的脚本, 所有例子都可以在 Windows, Solaris, 以及 Linux 下正常执行.
所有代码都是有版权的. 当然,你可以自由地使用这些这些模块,别忘记你是从哪得到(?学会)这些的.
0.4. 如何联系我们
1. 核心模块
1.1. 介绍
Python 的标准库包括了很多的模块, 从 Python 语言自身特定的类型和声明, 到一些只用于少数程序的不著名的模块.
本章描述了一些基本的标准库模块. 任何大型 Python 程序都有可能直接或间接地使用到这类模块的大部分.
1.1.1. 内建函数和异常
下面的这两个模块比其他模块加在一起还要重要: 定义内建函数(例如 len, int, range …)的 _ _builtin_ _
模块, 以及定义所有内建异常的 exceptions
模块.
Python 在启动时导入这两个模块, 使任何程序都能够使用它们.
1.1.2. 操作系统接口模块
Python 有许多使用了 POSIX 标准 API 和标准 C 语言库的模块. 它们为底层操作系统提供了平台独立的接口.
[!Feather注: datetime 为 Py2.3 新增模块, 提供增强的时间处理方法 ]
延伸一点说, 网络和线程模块同样也可以归为这一个类型. 不过 Python 并没有在所有的平台/版本实现这些.
1.1.3. 类型支持模块
1.1.4. 正则表达式
re
模块为 Python 提供了正则表达式支持. 正则表达式是用于匹配字符串或特定子字符串的 有特定语法的字符串模式.
1.1.5. 语言支持模块
1.2. _ _builtin_ _ 模块
这个模块包含 Python 中使用的内建函数. 一般不用手动导入这个模块; Python会帮你做好一切.
1.2.1. 使用元组或字典中的参数调用函数
Python允许你实时地创建函数参数列表. 只要把所有的参数放入一个元组中, 然后通过内建的 apply
函数调用函数. 如 Example 1-1.
1.2.1.1. Example 1-1. 使用 apply 函数
File: builtin-apply-example-1.pydef function(a, b):print a, bapply(function, ("whither", "canada?")) apply(function, (1, 2 + 3))whither canada? 1 5
要想把关键字参数传递给一个函数, 你可以将一个字典作为 apply
函数的第 3 个参数, 参考 Example 1-2.
1.2.1.2. Example 1-2. 使用 apply 函数传递关键字参数
File: builtin-apply-example-2.pydef function(a, b):print a, bapply(function, ("crunchy", "frog")) apply(function, ("crunchy",), {"b": "frog"}) apply(function, (), {"a": "crunchy", "b": "frog"})crunchy frog crunchy frog crunchy frog
apply
函数的一个常见用法是把构造函数参数从子类传递到基类, 尤其是构造函数需要接受很多参数的时候. 如 Example 1-3 所示.
1.2.1.3. Example 1-3. 使用 apply 函数调用基类的构造函数
File: builtin-apply-example-3.pyclass Rectangle:def _ _init_ _(self, color="white", width=10, height=10):print "create a", color, self, "sized", width, "x", heightclass RoundedRectangle(Rectangle):def _ _init_ _(self, **kw):apply(Rectangle._ _init_ _, (self,), kw)rect = Rectangle(color="green", height=100, width=100) rect = RoundedRectangle(color="blue", height=20)create a green <Rectangle instance at 8c8260> sized 100 x 100 create a blue <RoundedRectangle instance at 8c84c0> sized 10 x 20
Python 2.0 提供了另个方法来做相同的事. 你只需要使用一个传统的函数调用 , 使用 *
来标记元组, **
来标记字典.
下面两个语句是等价的:
result = function(*args, **kwargs) result = apply(function, args, kwargs)
1.2.2. 加载和重载模块
通过这个戏法你可以动态地调用函数. 当你只知道模块名称(字符串)的时候, 这将很方便. Example 1-4 展示了这种用法, 动态地导入所有以 “-plugin
” 结尾的模块.
1.2.2.1. Example 1-4. 使用 _ _import_ _ 函数加载模块
File: builtin-import-example-1.pyimport glob, osmodules = []for module_file in glob.glob("*-plugin.py"):try:module_name, ext = os.path.splitext(os.path.basename(module_file))module = _ _import_ _(module_name)modules.append(module)except ImportError:pass # ignore broken modules
http://www.taodudu.cc/news/show-3346428.html
相关文章:
- Python2.0 模块大全
- python 各种模块学习
- 实战篇:SEK之买卖方向成交量分析
- Python 模块大全(很详细!)
- Linux指令4-文本处理(grep,sek,awk)
- java 获取屏幕_java 获取屏幕大小
- Android 11 之后,获取 Android 手机屏幕的尺寸(英寸)
- Java实现飞机大战游戏思路
- Java之简易版飞机大战
- 关于java实现简单的售货机程序
- 【Java】Java基础飞机大战小游戏完整代码
- java实现屏幕截图功能
- 飞机大战Java源代码
- Java版本飞机大战
- 写一个JAVA飞机大战小游戏AirPlaneWar
- Java获取键盘屏幕输入简单方法
- java获取鼠标在屏幕中的位置 方法一_Java如何获取鼠标指针的位置?
- java获取鼠标在屏幕位置的颜色RGB值
- 通过java获取手机信息_android获取手机信息
- 如何使用java代码获取屏幕显示器个数
- java从屏幕输入数据_java键盘输入/屏幕输出练习
- java 获取分辨率_如何在java中获得屏幕分辨率?
- JAVA 实现《飞机大战-I》游戏
- Java获取屏幕真实分辨率
- java实现获取手机设备号_Java 安卓获得获得手机设备信息
- 入户深圳的五种方式
- 计算机一级可以积分入深户吗,计算机软考中级能入深户吗?怎样报名考取
- 宝安区2021年高考成绩查询入口,2021年宝安区学位申请积分入学积分办法
- 软考中级怎么入户深圳,需要什么条件?
- 【新政策】2021年全日制大专学历持软考中级证书可入户深圳
python 模块大全相关推荐
- Python 模块大全(很详细!)
转载:.... Python的模块大全,很全,有详细介绍! 另外附Python两个教程 1. Python详细教程(廖雪峰的官方网站,语言简洁!) 2. Python 进阶教程 (Vamei) 3. ...
- python模块大全下载_Python及其常用模块库下载及安装
一.Python下载:https://www.python.org/downloads/ 二.Python模块下载:http://www.lfd.uci.edu/~gohlke/pythonlibs/ ...
- python模块大全_哎呀,不错哦!3步带你用Python打造一款智能语音聊天小软件
最近小编与中科院的同学吃饭的时候,偶然讲起来他最近的一个项目就是利用语音识别的技术和聊天机器人来实现人机交互,简而言之就是我们说话,程序识别出来我们讲的是什么,然后通过聊天机器人跟我们实现交流.我感到 ...
- python模块大全使用说明_python模块详解
使用python时,常常会涉及到库的调用,这就需要掌握模块的基本知识.本文分为如下几个部分 概念说明 模块的简单调用 包的导入 特殊的__init__.py文件 导入模块的搜索路径 __all__ 绝 ...
- python 模块大全_python第三方模块有哪些
今天给大家整理了python常用的第三方库,一起来看一下吧. 1.Requests.Kenneth Reitz写的最富盛名的http库.每个Python程序员都应该有它. 2.Scrapy.如果你从事 ...
- python模块大全doc_Python pydoc模块详解:查看、生成帮助文档
前面己经介绍了为函数.类.方法等编写文档(只要在函数.类.方法定义后定义一个字符串即可).前面也介绍了使用 help() 函数和 __doc__ 属性来查看函数.类.方法的文档,但这种方式总是在控制器 ...
- python模块大全doc_Python doc8包_程序模块 - PyPI - Python中文网
命令行用法$ doc8 -h usage: doc8 [-h] [--config path] [--allow-long-titles] [--ignore code] [--no-sphinx] ...
- Python2.0 模块大全
博客 学院 下载 更多 写博客 qq779488143 Python 模块大全(很详细!) 转载 2014年12月12日 20:47:18 标签: Python / 模块 / 教程 3694 转载:. ...
- python的html模块,python模块之HTMLParser
HTMLParser是python用来解析html的模块.它可以分析出html里面的标签.数据等等,是一种处理html的简便途径. HTMLParser采用的是一种事件驱动的模式,当HTMLParse ...
最新文章
- boost::mp11::mp_copy_if_q相关用法的测试程序
- rabittmq java spring_消息队列 RabbitMQ 与 Spring 整合使用的实例代码
- Android Studio开发基础之Context用法说明
- kubernetes系列10—存储卷详解
- python - 内置函数
- matlab制作强光效果代码,自己动手做一个雷达PPI显示器的动态效果图(附Matlab代码)...
- SQLite学习笔记
- Adobe reader 添加注释后,点击保存,强制要求另存为
- 什么是计算机网络中域名,什么是域名?
- Xamarin for android学习总结一
- 安利几个堪称黑科技的电脑软件
- Facebook投放广告总被拒?教你搞定FB广告投放
- java毕业设计——基于java+J2ME的贪吃蛇游戏设计与实现(毕业论文+程序源码)——贪吃蛇游戏
- 各种居中、对齐、页面布局问题,整理思路╮(╯▽╰)╭
- python、cpython、IPython、Jython区别
- java——数组和方法
- 多媒体高精度定时器介绍
- 文本框控件TextBox(文本类控件)
- 谁有快狐app苹果下载地址_苹果硅到底有多快?
- 十大经典排序算法时间复杂度和空间复杂度总结