Python常用库

• atexit allows you to register functions for your program to call when it exits. 在程序的任何地方都可以注册一个或多个回调函数,在程序退出时执行

• argparse provides functions for parsing command line arguments. 解析命令行参数

• bisect provides bisection algorithms for sorting lists (see Chapter 10). 二分算法, 实现了一个算法用于插入元素到有序列表

• calendar provides a number of date-related functions. 日历相关

• codecs provides functions for encoding and decoding data. 编解码相关 encode/decode相关

• collections provides a variety of useful data structures. 有用的工具类, 额外的数据结构 包含Counter, deque, defaultdict, namedtuple, OrderedDict

• copy provides functions for copying data. copy模块 深拷贝 浅拷贝

• csv provides functions for reading and writing CSV files. csv文件操作

• datetime provides classes for handling dates and times. 日期时间相关

• fnmatch provides functions for matching Unix-style filename patterns. 文件名模式匹配

• concurrent provides asynchronous computation (native in Python 3, available for Python 2 via PyPI). 异步协程相关

• glob provides functions for matching Unix-style path patterns. 文件名模式匹配

• io provides functions for handling I/O streams. In Python 3, it also contains StringIO (inside the module of the same name in Python 2), which allows you to treat strings as files. io相关

• json provides functions for reading and writing data in JSON format. json相关

• logging provides access to Python’s own built-in logging functionality. 日志

• multiprocessing allows you to run multiple subprocesses from your application, while providing an API that makes them look like threads. 多进程

• operator provides functions implementing the basic Python operators, which you can use instead of having to write your own lambda expressions (see Chapter 10). 操作符相关,算术/比较

• os provides access to basic OS functions. os相关

• random provides functions for generating pseudorandom numbers. 随机数相关

• re provides regular expression functionality. re正则相关

• sched provides an event scheduler without using multithreading. 事件调度器, 可用于实现定时任务 • select provides access to the select() and poll() functions for creating event loops. select模块

• shutil provides access to high-level file functions. 高层次的文件操作工具, 对文件的复制与删除操作更是比较支持好

• signal provides functions for handling POSIX signals. **signal模块, 处理posix信号 **

• tempfile provides functions for creating temporary files and directories. 创建临时文件和目录,用完后会自动删除

• threading provides access to high-level threading functionality. 线程

• urllib (and urllib2 and urlparse in Python 2.x) provides functions for handling and parsing URLs. urllib处理解析URL相关

• uuid allows you to generate Universally Unique Identifiers (UUIDs). 随机UUID生成

• itertools 迭代器相关操作封装 chain合并

• functool 比如 lru_cache缓存 partial 把一个函数的某些参数给固定住,返回一个新的函数 wraps 使用@装饰器时,保留原有函数的名称和docstring

来自《Serious Python》