# -*- coding: utf-8 -*-
# Autogenerated by Sphinx on Tue Jun 12 00:39:48 2018
topics = {'assert': 'The "assert" statement\n'
'**********************\n'
'\n'
'Assert statements are a convenient way to insert debugging '
'assertions\n'
'into a program:\n'
'\n'
' assert_stmt ::= "assert" expression ["," expression]\n'
'\n'
'The simple form, "assert expression", is equivalent to\n'
'\n'
' if __debug__:\n'
' if not expression: raise AssertionError\n'
'\n'
'The extended form, "assert expression1, expression2", is '
'equivalent to\n'
'\n'
' if __debug__:\n'
' if not expression1: raise AssertionError(expression2)\n'
'\n'
'These equivalences assume that "__debug__" and "AssertionError" '
'refer\n'
'to the built-in variables with those names. In the current\n'
'implementation, the built-in variable "__debug__" is "True" under\n'
'normal circumstances, "False" when optimization is requested '
'(command\n'
'line option -O). The current code generator emits no code for an\n'
'assert statement when optimization is requested at compile time. '
'Note\n'
'that it is unnecessary to include the source code for the '
'expression\n'
'that failed in the error message; it will be displayed as part of '
'the\n'
'stack trace.\n'
'\n'
'Assignments to "__debug__" are illegal. The value for the '
'built-in\n'
'variable is determined when the interpreter starts.\n',
'assignment': 'Assignment statements\n'
'*********************\n'
'\n'
'Assignment statements are used to (re)bind names to values and '
'to\n'
'modify attributes or items of mutable objects:\n'
'\n'
' assignment_stmt ::= (target_list "=")+ (starred_expression '
'| yield_expression)\n'
' target_list ::= target ("," target)* [","]\n'
' target ::= identifier\n'
' | "(" [target_list] ")"\n'
' | "[" [target_list] "]"\n'
' | attributeref\n'
' | subscription\n'
' | slicing\n'
' | "*" target\n'
'\n'
'(See section Primaries for the syntax definitions for '
'*attributeref*,\n'
'*subscription*, and *slicing*.)\n'
'\n'
'An assignment statement evaluates the expression list '
'(remember that\n'
'this can be a single expression or a comma-separated list, the '
'latter\n'
'yielding a tuple) and assigns the single resulting object to '
'each of\n'
'the target lists, from left to right.\n'
'\n'
'Assignment is defined recursively depending on the form of the '
'target\n'
'(list). When a target is part of a mutable object (an '
'attribute\n'
'reference, subscription or slicing), the mutable object must\n'
'ultimately perform the assignment and decide about its '
'validity, and\n'
'may raise an exception if the assignment is unacceptable. The '
'rules\n'
'observed by various types and the exceptions raised are given '
'with the\n'
'definition of the object types (see section The standard type\n'
'hierarchy).\n'
'\n'
'Assignment of an object to a target list, optionally enclosed '
'in\n'
'parentheses or square brackets, is recursively defined as '
'follows.\n'
'\n'
'* If the target list is empty: The object must also be an '
'empty\n'
' iterable.\n'
'\n'
'* If the target list is a single target in parentheses: The '
'object\n'
' is assigned to that target.\n'
'\n'
'* If the target list is a comma-separated list of targets, or '
'a\n'
' single target in square brackets: The object must be an '
'iterable\n'
' with the same number of items as there are targets in the '
'target\n'
' list, and the items are assigned, from left to right, to '
'the\n'
' corresponding targets.\n'
'\n'
' * If the target list contains one target prefixed with an\n'
' asterisk, called a “starred” target: The object must be '
'an\n'
' iterable with at least as many items as there are targets '
'in the\n'
' target list, minus one. The first items of the iterable '
'are\n'
' assigned, from left to right, to the targets before the '
'starred\n'
' target. The final items of the iterable are assigned to '
'the\n'
' targets after the starred target. A list of the remaining '
'items\n'
' in the iterable is then assigned to the starred target '
'(the list\n'
' can be empty).\n'
'\n'
' * Else: The object must be an iterable with the same number '
'of\n'
' items as there are targets in the target list, and the '
'items are\n'
' assigned, from left to right, to the corresponding '
'targets.\n'
'\n'
'Assignment of an object to a single target is recursively '
'defined as\n'
'follows.\n'
'\n'
'* If the target is an identifier (name):\n'
'\n'
' * If the name does not occur in a "global" or "nonlocal" '
'statement\n'
' in the current code block: the name is bound to the object '
'in the\n'
' current local namespace.\n'
'\n'
' * Otherwise: the name is bound to the object in the global\n'
' namespace or the outer namespace determined by '
'"nonlocal",\n'
' respectively.\n'
'\n'
' The name is rebound if it was already bound. This may cause '
'the\n'
' reference count for the object previously bound to the name '
'to reach\n'
' zero, causing the object to be deallocated and its '
'destructor (if it\n'
' has one) to be called.\n'
'\n'
'* If the target is an attribute reference: The primary '
'expression in\n'
' the reference is evaluated. It should yield an object with\n'
' assignable attributes; if this is not the case, "TypeError" '
'is\n'
' raised. That object is then asked to assign the assigned '
'object to\n'
' the given attribute; if it cannot perform the assignment, it '
'raises\n'
' an e
python3.7的扩展包
需积分: 0 45 浏览量
更新于2023-10-13
收藏 62.43MB RAR 举报
Python 3.7 是 Python 语言的一个重要版本,它引入了许多新特性,改进了性能,并且增强了语言的稳定性。在Python的世界中,扩展包(也称为库或模块)是编程者能够利用的强大工具,它们提供了丰富的功能,帮助开发者快速实现各种复杂的任务。本文将深入探讨Python 3.7中的扩展包及其重要性。
1. **标准库**:Python 3.7的标准库包含了大量预先编写的模块,如os、sys、math、json、datetime等。这些模块提供了操作系统交互、系统信息获取、数学计算、数据序列化等功能。例如,os模块用于进行文件和目录操作,sys模块则用来处理与Python解释器相关的任务。
2. **第三方库**:除了标准库,Python社区还开发了大量的第三方扩展包,可以通过pip(Python的包管理器)安装。这些库通常托管在PyPI(Python Package Index)上,如numpy、pandas、matplotlib等。numpy是科学计算的基础,提供了高效的多维数组操作;pandas是数据分析的核心库,提供灵活的数据结构和数据分析工具;matplotlib则是用于数据可视化的库,支持创建各种图表。
3. **虚拟环境**:在Python 3.7中,可以使用venv模块创建独立的运行环境,每个环境中可以安装特定版本的扩展包,避免了不同项目之间因依赖冲突而产生的问题。这有助于保持开发环境的整洁和可重复性。
4. **类型注解**:Python 3.7引入了更完善的类型注解,这使得代码更具可读性和可维护性。类型注解可以用于静态类型检查工具,如mypy,以检测可能的类型错误。
5. **异步编程**:Python 3.7进一步完善了异步I/O模型,引入了asyncio库,支持协程(coroutine)和异步函数,使得编写高性能的网络应用变得更加容易。例如,使用aiohttp库可以方便地进行异步HTTP请求。
6. **数据结构改进**:Python 3.7对字典(dict)进行了优化,保证了插入顺序,这在某些情况下非常有用,比如日志记录或JSON序列化。同时,集合(set)操作也更加高效。
7. **异常处理**:Python 3.7允许在except语句中指定多个异常类型,提高了代码的简洁性。
8. **f-string**:Python 3.7引入了f-string(格式化字符串字面量),这是一种新的字符串格式化方式,可以更直观地将变量插入到字符串中,提高了代码的可读性。
9. **垃圾回收**:Python的垃圾回收机制在3.7版本中得到了优化,能更好地处理循环引用问题,提升了内存管理效率。
10. **增强的交互模式**:Python 3.7的交互模式提供了更好的反馈,例如显示行号和执行时间,这对于调试和学习都非常有帮助。
Python 3.7的扩展包生态系统极大地丰富了开发者的工具箱,无论是基础的系统操作,还是复杂的科学计算和数据分析,甚至是现代Web开发和机器学习,都有相应的扩展包来支持。通过有效利用这些扩展包,开发者可以更高效、更便捷地完成各种任务,提高生产力。

从小就文静
- 粉丝: 0
- 资源: 3
最新资源
- 微同商城-uniapp资源
- mlsql-机器学习资源
- CFRP/钛叠层钻削温度场仿真与切屑效应解析(含详细可运行代码及解释)
- OpenMLDB-深度学习资源
- pytorch-aarch64-pytorch资源
- JeeSite-typescript资源
- StudyGameUE5-UE开发资源
- RFID-RFID资源
- (源码)基于C++和Unitree SDK的Go1机器人控制项目.zip
- 大学生活动社交小程序-活动资源
- DeepSeek-DeepSeek资源
- (源码)基于[未提及语言]的自动水箱填充系统.zip
- (源码)基于博弈理论的师徒技能学习模型.zip
- (源码)基于Qt框架的自定义控件和组件库.zip
- jeewx-boot-活动资源
- (源码)基于Arduino编程语言的LED闪烁控制项目.zip