An open API service indexing awesome lists of open source software.

https://github.com/liaogx/python3-cookbook

Python程序员进阶必备,深入理解Python语言机制和现代编程风格,内容涉及标准库、框架和应用程序中广泛使用的高级技术。
https://github.com/liaogx/python3-cookbook

cookbooks python3 python3-library

Last synced: 6 months ago
JSON representation

Python程序员进阶必备,深入理解Python语言机制和现代编程风格,内容涉及标准库、框架和应用程序中广泛使用的高级技术。

Awesome Lists containing this project

README

          

# python3-cookbook
> Python程序员进阶必备,深入理解Python语言机制和现代编程风格,内容涉及标准库、框架和应用程序中广泛使用的高级技术。

## 第一章

- [1.1 解压序列赋值给多个变量](https://python3-cookbook.readthedocs.io/zh_CN/latest/c01/p01_unpack_sequence_into_separate_variables.html)
- [1.2 解压可迭代对象赋值给多个变量](https://python3-cookbook.readthedocs.io/zh_CN/latest/c01/p02_unpack_elements_from_iterables.html)
- [1.3 保留最后 N 个元素](https://python3-cookbook.readthedocs.io/zh_CN/latest/c01/p03_keep_last_n_items.html)
- [1.4 查找最大或最小的 N 个元素](https://python3-cookbook.readthedocs.io/zh_CN/latest/c01/p04_find_largest_or_smallest_n_items.html)
- [1.5 实现一个优先级队列](https://python3-cookbook.readthedocs.io/zh_CN/latest/c01/p05_implement_a_priority_queue.html)
- [1.6 字典中的键映射多个值](https://python3-cookbook.readthedocs.io/zh_CN/latest/c01/p06_map_keys_to_multiple_values_in_dict.html)
- [1.7 字典排序](https://python3-cookbook.readthedocs.io/zh_CN/latest/c01/p07_keep_dict_in_order.html)
- [1.8 字典的运算](https://python3-cookbook.readthedocs.io/zh_CN/latest/c01/p08_calculating_with_dict.html)
- [1.9 查找两字典的相同点](https://python3-cookbook.readthedocs.io/zh_CN/latest/c01/p09_find_commonalities_in_dicts.html)
- [1.10 删除序列相同元素并保持顺序](https://python3-cookbook.readthedocs.io/zh_CN/latest/c01/p10_remove_duplicates_from_seq_order.html)
- [1.11 命名切片](https://python3-cookbook.readthedocs.io/zh_CN/latest/c01/p11_naming_slice.html)
- [1.12 序列中出现次数最多的元素](https://python3-cookbook.readthedocs.io/zh_CN/latest/c01/p12_determine_most_freqently_items_in_seq.html)
- [1.13 通过某个关键字排序一个字典列表](https://python3-cookbook.readthedocs.io/zh_CN/latest/c01/p13_sort_list_of_dicts_by_key.html)
- [1.14 排序不支持原生比较的对象](https://python3-cookbook.readthedocs.io/zh_CN/latest/c01/p14_sort_objects_without_compare_support.html)
- [1.15 通过某个字段将记录分组](https://python3-cookbook.readthedocs.io/zh_CN/latest/c01/p15_group_records_based_on_field.html)
- [1.16 过滤序列元素](https://python3-cookbook.readthedocs.io/zh_CN/latest/c01/p16_filter_sequence_elements.html)
- [1.17 从字典中提取子集](https://python3-cookbook.readthedocs.io/zh_CN/latest/c01/p17_extract_subset_of_dict.html)
- [1.18 映射名称到序列元素](https://python3-cookbook.readthedocs.io/zh_CN/latest/c01/p18_map_names_to_sequence_elements.html)
- [1.19 转换并同时计算数据](https://python3-cookbook.readthedocs.io/zh_CN/latest/c01/p19_transform_and_reduce_data_same_time.html)
- [1.20 合并多个字典或映射](https://python3-cookbook.readthedocs.io/zh_CN/latest/c01/p20_combine_multiple_map_to_single_map.html)

## 第二章

- [2.1 使用多个界定符分割字符串](https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p01_split_string_on_multiple_delimiters.html)
- [2.2 字符串开头或结尾匹配](https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p02_match_text_at_start_end.html)
- [2.3 用Shell通配符匹配字符串](https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p03_match_strings_with_shell_wildcard.html)
- [2.4 字符串匹配和搜索](https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p04_match_and_search_text.html)
- [2.5 字符串搜索和替换](https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p05_search_and_replace_text.html)
- [2.6 字符串忽略大小写的搜索替换](https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p06_search_replace_case_insensitive.html)
- [2.7 最短匹配模式](https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p07_specify_regexp_for_shortest_match.html)
- [2.8 多行匹配模式](https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p08_regexp_for_multiline_partterns.html)
- [2.9 将Unicode文本标准化](https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p09_normalize_unicode_text_to_regexp.html)
- [2.10 在正则式中使用Unicode](https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p10_work_with_unicode_in_regexp.html)
- [2.11 删除字符串中不需要的字符](https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p11_strip_unwanted_characters.html)
- [2.12 审查清理文本字符串](https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p12_sanitizing_clean_up_text.html)
- [2.13 字符串对齐](https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p13_aligning_text_strings.html)
- [2.14 合并拼接字符串](https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p14_combine_and_concatenate_strings.html)
- [2.15 字符串中插入变量](https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p15_interpolating_variables_in_strings.html)
- [2.16 以指定列宽格式化字符串](https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p16_reformat_text_to_fixed_number_columns.html)
- [2.17 在字符串中处理html和xml](https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p17_handle_html_xml_in_text.html)
- [2.18 字符串令牌解析](https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p18_tokenizing_text.html)
- [2.19 实现一个简单的递归下降分析器](https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p19_writing_recursive_descent_parser.html)
- [2.20 字节字符串上的字符串操作](https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p20_perform_text_operations_on_byte_string.html)

## 第三章

- [3.1 数字的四舍五入](https://python3-cookbook.readthedocs.io/zh_CN/latest/c03/p01_round_number.html)
- [3.2 执行精确的浮点数运算](https://python3-cookbook.readthedocs.io/zh_CN/latest/c03/p02_accurate_decimal_calculations.html)
- [3.3 数字的格式化输出](https://python3-cookbook.readthedocs.io/zh_CN/latest/c03/p03_format_numbers_for_output.html)
- [3.4 二八十六进制整数](https://python3-cookbook.readthedocs.io/zh_CN/latest/c03/p04_binary_octal_hexadecimal_int.html)
- [3.5 字节到大整数的打包与解包](https://python3-cookbook.readthedocs.io/zh_CN/latest/c03/p05_pack_unpack_large_int_from_bytes.html)
- [3.6 复数的数学运算](https://python3-cookbook.readthedocs.io/zh_CN/latest/c03/p06_complex_math.html)
- [3.7 无穷大与NaN](https://python3-cookbook.readthedocs.io/zh_CN/latest/c03/p07_infinity_and_nan.html)
- [3.8 分数运算](https://python3-cookbook.readthedocs.io/zh_CN/latest/c03/p08_calculating_with_fractions.html)
- [3.9 大型数组运算](https://python3-cookbook.readthedocs.io/zh_CN/latest/c03/p09_calculating_with_large_num_arrays.html)
- [3.10 矩阵与线性代数运算](https://python3-cookbook.readthedocs.io/zh_CN/latest/c03/p10_matrix_and_linear_algebra_calculation.html)
- [3.11 随机选择](https://python3-cookbook.readthedocs.io/zh_CN/latest/c03/p11_pick_things_at_random.html)
- [3.12 基本的日期与时间转换](https://python3-cookbook.readthedocs.io/zh_CN/latest/c03/p12_convert_days_to_seconds_and_others.html)
- [3.13 计算最后一个周五的日期](https://python3-cookbook.readthedocs.io/zh_CN/latest/c03/p13_determine_last_friday_date.html)
- [3.14 计算当前月份的日期范围](https://python3-cookbook.readthedocs.io/zh_CN/latest/c03/p14_date_range_for_current_month.html)
- [3.15 字符串转换为日期](https://python3-cookbook.readthedocs.io/zh_CN/latest/c03/p15_convert_strings_into_datetimes.html)
- [3.16 结合时区的日期操作](https://python3-cookbook.readthedocs.io/zh_CN/latest/c03/p16_manipulate_dates_involving_timezone.html)

## 第四章

- [4.1 手动遍历迭代器](https://python3-cookbook.readthedocs.io/zh_CN/latest/c04/p01_manually_consuming_iterator.html)
- [4.2 代理迭代](https://python3-cookbook.readthedocs.io/zh_CN/latest/c04/p02_delegating_iteration.html)
- [4.3 使用生成器创建新的迭代模式](https://python3-cookbook.readthedocs.io/zh_CN/latest/c04/p03_create_new_iteration_with_generators.html)
- [4.4 实现迭代器协议](https://python3-cookbook.readthedocs.io/zh_CN/latest/c04/p04_implement_iterator_protocol.html)
- [4.5 反向迭代](https://python3-cookbook.readthedocs.io/zh_CN/latest/c04/p05_iterating_in_reverse.html)
- [4.6 带有外部状态的生成器函数](https://python3-cookbook.readthedocs.io/zh_CN/latest/c04/p06_define_generator_func_with_extra_state.html)
- [4.7 迭代器切片](https://python3-cookbook.readthedocs.io/zh_CN/latest/c04/p07_taking_slice_of_iterator.html)
- [4.8 跳过可迭代对象的开始部分](https://python3-cookbook.readthedocs.io/zh_CN/latest/c04/p08_skip_first_part_of_iterable.html)
- [4.9 排列组合的迭代](https://python3-cookbook.readthedocs.io/zh_CN/latest/c04/p09_iterate_over_combination_or_permutation.html)
- [4.10 序列上索引值迭代](https://python3-cookbook.readthedocs.io/zh_CN/latest/c04/p10_iterate_over_index_value_pairs_of_sequence.html)
- [4.11 同时迭代多个序列](https://python3-cookbook.readthedocs.io/zh_CN/latest/c04/p11_iterate_over_multiple_sequences_simultaneously.html)
- [4.12 不同集合上元素的迭代](https://python3-cookbook.readthedocs.io/zh_CN/latest/c04/p12_iterate_on_items_in_separate_containers.html)
- [4.13 创建数据处理管道](https://python3-cookbook.readthedocs.io/zh_CN/latest/c04/p13_create_data_processing_pipelines.html)
- [4.14 展开嵌套的序列](https://python3-cookbook.readthedocs.io/zh_CN/latest/c04/p14_flattening_nested_sequence.html)
- [4.15 顺序迭代合并后的排序迭代对象](https://python3-cookbook.readthedocs.io/zh_CN/latest/c04/p15_iterate_in_sorted_order_over_merged_sorted_iterables.html)
- [4.16 迭代器代替while无限循环](https://python3-cookbook.readthedocs.io/zh_CN/latest/c04/p16_replace_infinite_while_loops_with_iterator.html)

## 第五章

- [5.1 读写文本数据](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p01_read_write_text_data.html)
- [5.2 打印输出至文件中](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p02_printing_to_file.html)
- [5.3 使用其他分隔符或行终止符打印](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p03_print_with_different_separator_or_line_ending.html)
- [5.4 读写字节数据](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p04_read_write_binary_data.html)
- [5.5 文件不存在才能写入](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p05_write_to_file_not_exist.html)
- [5.6 字符串的I/O操作](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p06_io_operations_on_string.html)
- [5.7 读写压缩文件](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p07_read_write_compressed_datafiles.html)
- [5.8 固定大小记录的文件迭代](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p08_iterate_over_fixed_sized_records.html)
- [5.9 读取二进制数据到可变缓冲区中](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p09_read_binary_data_into_mutable_buffer.html)
- [5.10 内存映射的二进制文件](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p10_memory_mapping_binary_files.html)
- [5.11 文件路径名的操作](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p11_manipulating_pathnames.html)
- [5.12 测试文件是否存在](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p12_test_for_the_existence_of_file.html)
- [5.13 获取文件夹中的文件列表](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p13_get_directory_listing.html)
- [5.14 忽略文件名编码](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p14_bypassing_filename_encoding.html)
- [5.15 打印不合法的文件名](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p15_printing_bad_filenames.html)
- [5.16 增加或改变已打开文件的编码](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p16_add_change_encoding_of_already_open_file.html)
- [5.17 将字节写入文本文件](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p17_write_bytes_to_text_file.html)
- [5.18 将文件描述符包装成文件对象](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p18_wrap_existing_file_descriptor_as_file_object.html)
- [5.19 创建临时文件和文件夹](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p19_make_temporary_files_and_directories.html)
- [5.20 与串行端口的数据通信](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p20_communicating_with_serial_ports.html)
- [5.21 序列化Python对象](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p21_serializing_python_objects.html)

## 第六章

- [6.1 读写CSV数据](https://python3-cookbook.readthedocs.io/zh_CN/latest/c06/p01_read_write_csv_data.html)
- [6.2 读写JSON数据](https://python3-cookbook.readthedocs.io/zh_CN/latest/c06/p02_read-write_json_data.html)
- [6.3 解析简单的XML数据](https://python3-cookbook.readthedocs.io/zh_CN/latest/c06/p03_parse_simple_xml_data.html)
- [6.4 增量式解析大型XML文件](https://python3-cookbook.readthedocs.io/zh_CN/latest/c06/p04_parse_huge_xml_files_incrementally.html)
- [6.5 将字典转换为XML](https://python3-cookbook.readthedocs.io/zh_CN/latest/c06/p05_turning_dictionary_into_xml.html)
- [6.6 解析和修改XML](https://python3-cookbook.readthedocs.io/zh_CN/latest/c06/p06_parse_modify_rewrite_xml.html)
- [6.7 利用命名空间解析XML文档](https://python3-cookbook.readthedocs.io/zh_CN/latest/c06/p07_parse_xml_documents_with_namespaces.html)
- [6.8 与关系型数据库的交互](https://python3-cookbook.readthedocs.io/zh_CN/latest/c06/p08_interact_with_relational_database.html)
- [6.9 编码和解码十六进制数](https://python3-cookbook.readthedocs.io/zh_CN/latest/c06/p09_decode_encode_hexadecimal_digits.html)
- [6.10 编码解码Base64数据](https://python3-cookbook.readthedocs.io/zh_CN/latest/c06/p10_decode_encode_base64.html)
- [6.11 读写二进制数组数据](https://python3-cookbook.readthedocs.io/zh_CN/latest/c06/p11_read_write_binary_arrays_of_structures.html)
- [6.12 读取嵌套和可变长二进制数据](https://python3-cookbook.readthedocs.io/zh_CN/latest/c06/p12_read_nested_and_variable_sized_binary_structures.html)
- [6.13 数据的累加与统计操作](https://python3-cookbook.readthedocs.io/zh_CN/latest/c06/p13_summarizing_and_perform_statistics.html)

## 第七章

- [7.1 可接受任意数量参数的函数](https://python3-cookbook.readthedocs.io/zh_CN/latest/c07/p01_functions_that_accept_any_number_arguments.html)
- [7.2 只接受关键字参数的函数](https://python3-cookbook.readthedocs.io/zh_CN/latest/c07/p02_functions_that_only_accept_keyword_arguments.html)
- [7.3 给函数参数增加元信息](https://python3-cookbook.readthedocs.io/zh_CN/latest/c07/p03_attach_informatinal_matadata_to_function_arguments.html)
- [7.4 返回多个值的函数](https://python3-cookbook.readthedocs.io/zh_CN/latest/c07/p04_return_multiple_values_from_function.html)
- [7.5 定义有默认参数的函数](https://python3-cookbook.readthedocs.io/zh_CN/latest/c07/p05_define_functions_with_default_arguments.html)
- [7.6 定义匿名或内联函数](https://python3-cookbook.readthedocs.io/zh_CN/latest/c07/p06_define_anonymous_or_inline_functions.html)
- [7.7 匿名函数捕获变量值](https://python3-cookbook.readthedocs.io/zh_CN/latest/c07/p07_capturing_variables_in_anonymous_functions.html)
- [7.8 减少可调用对象的参数个数](https://python3-cookbook.readthedocs.io/zh_CN/latest/c07/p08_make_callable_with_fewer_arguments.html)
- [7.9 将单方法的类转换为函数](https://python3-cookbook.readthedocs.io/zh_CN/latest/c07/p09_replace_single_method_classes_with_functions.html)
- [7.10 带额外状态信息的回调函数](https://python3-cookbook.readthedocs.io/zh_CN/latest/c07/p10_carry_extra_state_with_callback_functions.html)
- [7.11 内联回调函数](https://python3-cookbook.readthedocs.io/zh_CN/latest/c07/p11_inline_callback_functions.html)
- [7.12 访问闭包中定义的变量](https://python3-cookbook.readthedocs.io/zh_CN/latest/c07/p12_access_variables_defined_inside_closure.html)

## 第八章

- [8.1 改变对象的字符串显示](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p01_change_string_representation_of_instances.html)
- [8.2 自定义字符串的格式化](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p02_customizing_string_formatting.html)
- [8.3 让对象支持上下文管理协议](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p03_make_objects_support_context_management_protocol.html)
- [8.4 创建大量对象时节省内存方法](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p04_save_memory_when_create_large_number_instances.html)
- [8.5 在类中封装属性名](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p05_encapsulating_names_in_class.html)
- [8.6 创建可管理的属性](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p06_create_managed_attributes.html)
- [8.7 调用父类方法](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p07_calling_method_on_parent_class.html)
- [8.8 子类中扩展property](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p08_extending_property_in_subclass.html)
- [8.9 创建新的类或实例属性](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p09_create_new_kind_of_class_or_instance_attribute.html)
- [8.10 使用延迟计算属性](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p10_using_lazily_computed_properties.html)
- [8.11 简化数据结构的初始化](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p11_simplify_initialization_of_data_structure.html)
- [8.12 定义接口或者抽象基类](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p12_define_interface_or_abstract_base_class.html)
- [8.13 实现数据模型的类型约束](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p13_implementing_data_model_or_type_system.html)
- [8.14 实现自定义容器](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p14_implementing_custom_containers.html)
- [8.15 属性的代理访问](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p15_delegating_attribute_access.html)
- [8.16 在类中定义多个构造器](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p16_define_more_than_one_constructor_in_class.html)
- [8.17 创建不调用init方法的实例](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p17_create_instance_without_invoking_init_method.html)
- [8.18 利用Mixins扩展类功能](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p18_extending_classes_with_mixins.html)
- [8.19 实现状态对象或者状态机](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p19_implements_stateful_objects_or_state_machines.html)
- [8.20 通过字符串调用对象方法](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p20_call_method_on_object_by_string_name.html)
- [8.21 实现访问者模式](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p21_implementing_visitor_pattern.html)
- [8.22 不用递归实现访问者模式](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p22_implementing_visitor_pattern_without_recursion.html)
- [8.23 循环引用数据结构的内存管理](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p23_managing_memory_in_cyclic_data_structures.html)
- [8.24 让类支持比较操作](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p24_making_classes_support_comparison_operations.html)
- [8.25 创建缓存实例](https://python3-cookbook.readthedocs.io/zh_CN/latest/c08/p25_creating_cached_instances.html)

## 第九章

- [9.1 在函数上添加包装器](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p01_put_wrapper_around_function.html)
- [9.2 创建装饰器时保留函数元信息](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p02_preserve_function_metadata_when_write_decorators.html)
- [9.3 解除一个装饰器](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p03_unwrapping_decorator.html)
- [9.4 定义一个带参数的装饰器](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p04_define_decorator_that_takes_arguments.html)
- [9.5 可自定义属性的装饰器](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p05_define_decorator_with_user_adjustable_attributes.html)
- [9.6 带可选参数的装饰器](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p06_define_decorator_that_takes_optional_argument.html)
- [9.7 利用装饰器强制函数上的类型检查](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p07_enforcing_type_check_on_function_using_decorator.html)
- [9.8 将装饰器定义为类的一部分](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p08_define_decorators_as_part_of_class.html)
- [9.9 将装饰器定义为类](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p09_define_decorators_as_classes.html)
- [9.10 为类和静态方法提供装饰器](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p10_apply_decorators_to_class_and_static_methods.html)
- [9.11 装饰器为被包装函数增加参数](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p11_write_decorators_that_add_arguments_to_functions.html)
- [9.12 使用装饰器扩充类的功能](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p12_using_decorators_to_patch_class_definitions.html)
- [9.13 使用元类控制实例的创建](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p13_using_mataclass_to_control_instance_creation.html)
- [9.14 捕获类的属性定义顺序](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p14_capture_class_attribute_definition_order.html)
- [9.15 定义有可选参数的元类](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p15_define_metaclass_that_takes_optional_arguments.html)
- [9.16 *args和**kwargs的强制参数签名](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p16_enforce_argument_signature_on_args_kwargs.html)
- [9.17 在类上强制使用编程规约](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p17_enforce_coding_conventions_in_classes.html)
- [9.18 以编程方式定义类](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p18_define_classes_programmatically.html)
- [9.19 在定义的时候初始化类的成员](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p19_initializing_class_members_at_definition_time.html)
- [9.20 利用函数注解实现方法重载](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p20_implement_multiple_dispatch_with_function_annotations.html)
- [9.21 避免重复的属性方法](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p21_avoid_repetitive_property_methods.html)
- [9.22 定义上下文管理器的简单方法](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p22_define_context_managers_the_easy_way.html)
- [9.23 在局部变量域中执行代码](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p23_executing_code_with_local_side_effects.html)
- [9.24 解析与分析Python源码](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p24_parse_and_analyzing_python_source.html)
- [9.25 拆解Python字节码](https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p25_disassembling_python_byte_code.html)

## 第十章

- [10.1 构建一个模块的层级包](https://python3-cookbook.readthedocs.io/zh_CN/latest/c10/p01_make_hierarchical_package_of_modules.html)
- [10.2 控制模块被全部导入的内容](https://python3-cookbook.readthedocs.io/zh_CN/latest/c10/p02_control_the_import_of_everything.html)
- [10.3 使用相对路径名导入包中子模块](https://python3-cookbook.readthedocs.io/zh_CN/latest/c10/p03_import_submodules_by_relative_names.html)
- [10.4 将模块分割成多个文件](https://python3-cookbook.readthedocs.io/zh_CN/latest/c10/p04_split_module_into_multiple_files.html)
- [10.5 利用命名空间导入目录分散的代码](https://python3-cookbook.readthedocs.io/zh_CN/latest/c10/p05_separate_directories_import_by_namespace.html)
- [10.6 重新加载模块](https://python3-cookbook.readthedocs.io/zh_CN/latest/c10/p06_reloading_modules.html)
- [10.7 运行目录或压缩文件](https://python3-cookbook.readthedocs.io/zh_CN/latest/c10/p07_make_directory_or_zip_runnable_as_main_script.html)
- [10.8 读取位于包中的数据文件](https://python3-cookbook.readthedocs.io/zh_CN/latest/c10/p08_read_datafile_within_package.html)
- [10.9 将文件夹加入到sys.path](https://python3-cookbook.readthedocs.io/zh_CN/latest/c10/p09_add_directories_to_sys_path.html)
- [10.10 通过字符串名导入模块](https://python3-cookbook.readthedocs.io/zh_CN/latest/c10/p10_import_modules_using_name_given_in_string.html)
- [10.11 通过钩子远程加载模块](https://python3-cookbook.readthedocs.io/zh_CN/latest/c10/p11_load_modules_from_remote_machine_by_hooks.html)
- [10.12 导入模块的同时修改模块](https://python3-cookbook.readthedocs.io/zh_CN/latest/c10/p12_patching_modules_on_import.html)
- [10.13 安装私有的包](https://python3-cookbook.readthedocs.io/zh_CN/latest/c10/p13_installing_packages_just_for_yourself.html)
- [10.14 创建新的Python环境](https://python3-cookbook.readthedocs.io/zh_CN/latest/c10/p14_creating_new_python_environment.html)
- [10.15 分发包](https://python3-cookbook.readthedocs.io/zh_CN/latest/c10/p15_distributing_packages.html)

## 第十一章

- [11.1 作为客户端与HTTP服务交互](https://python3-cookbook.readthedocs.io/zh_CN/latest/c11/p01_interact_with_http_services_as_client.html)
- [11.2 创建TCP服务器](https://python3-cookbook.readthedocs.io/zh_CN/latest/c11/p02_creating_tcp_server.html)
- [11.3 创建UDP服务器](https://python3-cookbook.readthedocs.io/zh_CN/latest/c11/p03_creating_udp_server.html)
- [11.4 通过CIDR地址生成对应的IP地址集](https://python3-cookbook.readthedocs.io/zh_CN/latest/c11/p04_generate_range_of_ip_addresses_from_cidr_address.html)
- [11.5 创建一个简单的REST接口](https://python3-cookbook.readthedocs.io/zh_CN/latest/c11/p05_creating_simple_rest_based_interface.html)
- [11.6 通过XML-RPC实现简单的远程调用](https://python3-cookbook.readthedocs.io/zh_CN/latest/c11/p06_implement_simple_remote_procedure_call_with_xml_rpc.html)
- [11.7 在不同的Python解释器之间交互](https://python3-cookbook.readthedocs.io/zh_CN/latest/c11/p07_communicate_simply_between_interpreters.html)
- [11.8 实现远程方法调用](https://python3-cookbook.readthedocs.io/zh_CN/latest/c11/p08_implementing_remote_procedure_calls.html)
- [11.9 简单的客户端认证](https://python3-cookbook.readthedocs.io/zh_CN/latest/c11/p09_authenticating_clients_simply.html)
- [11.10 在网络服务中加入SSL](https://python3-cookbook.readthedocs.io/zh_CN/latest/c11/p10_add_ssl_to_network_services.html)
- [11.11 进程间传递Socket文件描述符](https://python3-cookbook.readthedocs.io/zh_CN/latest/c11/p11_pass_socket_file_descriptor_between_processes.html)
- [11.12 理解事件驱动的IO](https://python3-cookbook.readthedocs.io/zh_CN/latest/c11/p12_understanding_event_driven_io.html)
- [11.13 发送与接收大型数组](https://python3-cookbook.readthedocs.io/zh_CN/latest/c11/p13_sending_receiving_large_arrays.html)

## 第十二章

- [12.1 启动与停止线程](https://python3-cookbook.readthedocs.io/zh_CN/latest/c12/p01_start_stop_thread.html)
- [12.2 判断线程是否已经启动](https://python3-cookbook.readthedocs.io/zh_CN/latest/c12/p02_determining_if_thread_has_started.html)
- [12.3 线程间通信](https://python3-cookbook.readthedocs.io/zh_CN/latest/c12/p03_communicating_between_threads.html)
- [12.4 给关键部分加锁](https://python3-cookbook.readthedocs.io/zh_CN/latest/c12/p04_locking_critical_sections.html)
- [12.5 防止死锁的加锁机制](https://python3-cookbook.readthedocs.io/zh_CN/latest/c12/p05_locking_with_deadlock_avoidance.html)
- [12.6 保存线程的状态信息](https://python3-cookbook.readthedocs.io/zh_CN/latest/c12/p06_storing_thread_specific_state.html)
- [12.7 创建一个线程池](https://python3-cookbook.readthedocs.io/zh_CN/latest/c12/p07_creating_thread_pool.html)
- [12.8 简单的并行编程](https://python3-cookbook.readthedocs.io/zh_CN/latest/c12/p08_perform_simple_parallel_programming.html)
- [12.9 Python的全局锁问题](https://python3-cookbook.readthedocs.io/zh_CN/latest/c12/p09_dealing_with_gil_stop_worring_about_it.html)
- [12.10 定义一个Actor任务](https://python3-cookbook.readthedocs.io/zh_CN/latest/c12/p10_defining_an_actor_task.html)
- [12.11 实现消息发布/订阅模型](https://python3-cookbook.readthedocs.io/zh_CN/latest/c12/p11_implement_publish_subscribe_messaging.html)
- [12.12 使用生成器代替线程](https://python3-cookbook.readthedocs.io/zh_CN/latest/c12/p12_using_generators_as_alternative_to_threads.html)
- [12.13 多个线程队列轮询](https://python3-cookbook.readthedocs.io/zh_CN/latest/c12/p13_polling_multiple_thread_queues.html)
- [12.14 在Unix系统上面启动守护进程](https://python3-cookbook.readthedocs.io/zh_CN/latest/c12/p14_launching_daemon_process_on_unix.html)

## 第十三章

- [13.1 通过重定向/管道/文件接受输入](https://python3-cookbook.readthedocs.io/zh_CN/latest/c13/p01_accept_input_via_redirect_pips_or_input_files.html)
- [13.2 终止程序并给出错误信息](https://python3-cookbook.readthedocs.io/zh_CN/latest/c13/p02_terminate_program_with_an_error_message.html)
- [13.3 解析命令行选项](https://python3-cookbook.readthedocs.io/zh_CN/latest/c13/p03_parsing_command_line_options.html)
- [13.4 运行时弹出密码输入提示](https://python3-cookbook.readthedocs.io/zh_CN/latest/c13/p04_prompt_for_password_at_runtime.html)
- [13.5 获取终端的大小](https://python3-cookbook.readthedocs.io/zh_CN/latest/c13/p05_getting_terminal_size.html)
- [13.6 执行外部命令并获取它的输出](https://python3-cookbook.readthedocs.io/zh_CN/latest/c13/p06_executing_external_command_and_get_its_output.html)
- [13.7 复制或者移动文件和目录](https://python3-cookbook.readthedocs.io/zh_CN/latest/c13/p07_copy_move_files_and_directories.html)
- [13.8 创建和解压归档文件](https://python3-cookbook.readthedocs.io/zh_CN/latest/c13/p08_creating_and_unpacking_archives.html)
- [13.9 通过文件名查找文件](https://python3-cookbook.readthedocs.io/zh_CN/latest/c13/p09_find_files_by_name.html)
- [13.10 读取配置文件](https://python3-cookbook.readthedocs.io/zh_CN/latest/c13/p10_read_configuration_files.html)
- [13.11 给简单脚本增加日志功能](https://python3-cookbook.readthedocs.io/zh_CN/latest/c13/p11_add_logging_to_simple_scripts.html)
- [13.12 给函数库增加日志功能](https://python3-cookbook.readthedocs.io/zh_CN/latest/c13/p12_add_logging_to_libraries.html)
- [13.13 实现一个计时器](https://python3-cookbook.readthedocs.io/zh_CN/latest/c13/p13_making_stopwatch_timer.html)
- [13.14 限制内存和CPU的使用量](https://python3-cookbook.readthedocs.io/zh_CN/latest/c13/p14_putting_limits_on_memory_and_cpu_usage.html)
- [13.15 启动一个WEB浏览器](https://python3-cookbook.readthedocs.io/zh_CN/latest/c13/p15_luanch_a_web_browser.html)

## 第十四章

- [14.1 测试stdout输出](https://python3-cookbook.readthedocs.io/zh_CN/latest/c14/p01_testing_output_sent_to_stdout.html)
- [14.2 在单元测试中给对象打补丁](https://python3-cookbook.readthedocs.io/zh_CN/latest/c14/p02_patching_objects_in_unit_tests.html)
- [14.3 在单元测试中测试异常情况](https://python3-cookbook.readthedocs.io/zh_CN/latest/c14/p03_testing_for_exceptional_conditions_in_unit_tests.html)
- [14.4 将测试输出用日志记录到文件中](https://python3-cookbook.readthedocs.io/zh_CN/latest/c14/p04_logging_test_output_to_file.html)
- [14.5 忽略或期望测试失败](https://python3-cookbook.readthedocs.io/zh_CN/latest/c14/p05_skip_or_anticipate_test_failures.html)
- [14.6 处理多个异常](https://python3-cookbook.readthedocs.io/zh_CN/latest/c14/p06_handle_multiple_exceptions.html)
- [14.7 捕获所有异常](https://python3-cookbook.readthedocs.io/zh_CN/latest/c14/p07_catching_all_exceptions.html)
- [14.8 创建自定义异常](https://python3-cookbook.readthedocs.io/zh_CN/latest/c14/p08_creating_custom_exceptions.html)
- [14.9 捕获异常后抛出另外的异常](https://python3-cookbook.readthedocs.io/zh_CN/latest/c14/p09_raise_exception_in_response_to_another_exception.html)
- [14.10 重新抛出被捕获的异常](https://python3-cookbook.readthedocs.io/zh_CN/latest/c14/p10_reraising_the_last_exception.html)
- [14.11 输出警告信息](https://python3-cookbook.readthedocs.io/zh_CN/latest/c14/p11_issuing_warning_messages.html)
- [14.12 调试基本的程序崩溃错误](https://python3-cookbook.readthedocs.io/zh_CN/latest/c14/p12_debugging_basic_program_crashes.html)
- [14.13 给你的程序做性能测试](https://python3-cookbook.readthedocs.io/zh_CN/latest/c14/p13_profiling_and_timing_your_program.html)
- [14.14 加速程序运行](https://python3-cookbook.readthedocs.io/zh_CN/latest/c14/p14_make_your_program_run_faster.html)

## 第十五章

- [15.1 使用ctypes访问C代码](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p01_access_ccode_using_ctypes.html)
- [15.2 简单的C扩展模块](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p02_write_simple_c_extension_module.html)
- [15.3 编写扩展函数操作数组](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p03_write_extension_function_operate_on_arrays.html)
- [15.4 在C扩展模块中操作隐形指针](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p04_manage_opaque_pointers_in_c_extension_modules.html)
- [15.5 从扩展模块中定义和导出C的API](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p05_define_and_export_c_api_from_extension_modules.html)
- [15.6 从C语言中调用Python代码](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p06_calling_python_from_c.html)
- [15.7 从C扩展中释放全局锁](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p07_release_the_gil_in_c_extensions.html)
- [15.8 C和Python中的线程混用](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p08_mix_threads_from_c_and_python.html)
- [15.9 用WSIG包装C代码](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p09_wrap_c_code_with_swig.html)
- [15.10 用Cython包装C代码](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p10_wrap_existing_c_code_with_cython.html)
- [15.11 用Cython写高性能的数组操作](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p11_use_cython_to_write_high_performance_array_operation.html)
- [15.12 将函数指针转换为可调用对象](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p12_turning_function_pointer_into_callable.html)
- [15.13 传递NULL结尾的字符串给C函数库](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p13_pass_null_terminated_string_to_c_libraries.html)
- [15.14 传递Unicode字符串给C函数库](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p14_pass_unicode_strings_to_c_libraries.html)
- [15.15 C字符串转换为Python字符串](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p15_converting_c_string_to_python.html)
- [15.16 不确定编码格式的C字符串](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p16_work_with_c_strings_of_dubious_encoding.html)
- [15.17 传递文件名给C扩展](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p17_pass_filenames_to_c_extensions.html)
- [15.18 传递已打开的文件给C扩展](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p18_pass_open_files_to_c_extensions.html)
- [15.19 从C语言中读取类文件对象](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p19_read_file_like_objects_from_c.html)
- [15.20 处理C语言中的可迭代对象](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p20_consuming_an_iterable_from_c.html)
- [15.21 诊断分段错误](https://python3-cookbook.readthedocs.io/zh_CN/latest/c15/p21_diagnosing_segmentation_faults.html)