7wu1wm0 发表于 2024-8-18 05:10:08

Python术语对照表(下)

<span style="color: black;">magic method -- 魔术<span style="color: black;">办法</span>special method 的非正式同义词 。</span><span style="color: black;">mapping -- 映射一种支持任意键<span style="color: black;">查询</span>并实现了 </span><span style="color: black;"><span style="color: black;">Mapping</span></span><span style="color: black;"> 或 </span><span style="color: black;"><span style="color: black;">MutableMapping</span></span><span style="color: black;"> 抽象基类 中所规定<span style="color: black;">办法</span>的容器对象。 此类对象的例子<span style="color: black;">包含</span> </span><span style="color: black;"><span style="color: black;">dict</span></span><span style="color: black;">, </span><span style="color: black;"><span style="color: black;">collections.defaultdict</span></span><span style="color: black;">, </span><span style="color: black;"><span style="color: black;">collections.OrderedDict</span></span><span style="color: black;"> 以及 </span><span style="color: black;"><span style="color: black;">collections.Counter</span></span><span style="color: black;">。</span><span style="color: black;">meta path finder -- 元路径<span style="color: black;">查询</span>器</span><span style="color: black;"><span style="color: black;">sys.meta_path</span></span><span style="color: black;"> 的搜索所返回的 finder。元路径<span style="color: black;">查询</span>器与 path entry finders 存在<span style="color: black;">相关</span>但并不相同。请查看 </span><span style="color: black;"><span style="color: black;">importlib.abc.MetaPathFinder</span></span><span style="color: black;"> <span style="color: black;">认识</span>元路径<span style="color: black;">查询</span>器所实现的<span style="color: black;">办法</span>。</span><span style="color: black;">metaclass -- 元类一种用于创建类的类。类定义<span style="color: black;">包括</span>类名、类字典和基类列表。元类负责接受<span style="color: black;">以上</span>三个参数并创建相应的类。大部分面向对象的编程语言都会<span style="color: black;">供给</span>一个默认实现。Python 的<span style="color: black;">尤其</span>之处在于<span style="color: black;">能够</span>创建自定义元类。大部分用户永远不<span style="color: black;">必须</span>这个工具,但当<span style="color: black;">必须</span><span style="color: black;">显现</span>时,元类可<span style="color: black;">供给</span>强大而优雅的<span style="color: black;">处理</span><span style="color: black;">方法</span>。它们已被用于记录属性<span style="color: black;">拜访</span>日志、添加线程安全性、跟踪对象创建、实现单例,以及其他许多任务。<span style="color: black;">更加多</span>详情参见 元类。</span><span style="color: black;">method -- <span style="color: black;">办法</span>在类内部定义的函数。<span style="color: black;">倘若</span><span style="color: black;">做为</span>该类的实例的一个属性来调用,<span style="color: black;">办法</span>将会获取实例对象<span style="color: black;">做为</span>其<span style="color: black;">第1</span>个 argument (通常命名为 self)。参见 function 和 nested scope。</span><span style="color: black;">method resolution order -- <span style="color: black;">办法</span>解析<span style="color: black;">次序</span><span style="color: black;">办法</span>解析<span style="color: black;">次序</span><span style="color: black;">便是</span>在<span style="color: black;">查询</span>成员时搜索<span style="color: black;">所有</span>基类所用的先后<span style="color: black;">次序</span>。请查看 Python 2.3 <span style="color: black;">办法</span>解析<span style="color: black;">次序</span> <span style="color: black;">认识</span>自 2.3 版起 Python 解析器所用<span style="color: black;">关联</span>算法的详情。</span><span style="color: black;">module -- 模块此对象是 Python 代码的一种组织单位。各模块<span style="color: black;">拥有</span>独立的命名空间,可<span style="color: black;">包括</span>任意 Python 对象。模块可<span style="color: black;">经过</span> importing 操作被加载到 Python 中。另见 package。</span><span style="color: black;">module spec -- 模块规格一个命名空间,其中<span style="color: black;">包括</span>用于加载模块的<span style="color: black;">关联</span>导入信息。是</span><span style="color: black;"><span style="color: black;">importlib.machinery.ModuleSpec</span></span><span style="color: black;"> 的实例。</span><span style="color: black;">MRO参见 method resolution order。</span><span style="color: black;">mutable -- 可变可变对象<span style="color: black;">能够</span>在其 </span><span style="color: black;"><span style="color: black;">id()</span></span><span style="color: black;"> 保持固定的<span style="color: black;">状况</span>下改变其取值。另请参见 immutable。</span><span style="color: black;">named tuple -- 具名元组术语“具名元组”可用于任何继承自元组,并且其中的可索引元素还能<span style="color: black;">运用</span>名<span style="color: black;">叫作</span>属性来<span style="color: black;">拜访</span>的类型或类。 <span style="color: black;">这般</span>的类型或类还可能<span style="color: black;">持有</span>其他特性。有些内置类型属于具名元组,<span style="color: black;">包含</span></span><span style="color: black;"><span style="color: black;">time.localtime()</span></span><span style="color: black;"> 和 </span><span style="color: black;"><span style="color: black;">os.stat()</span></span><span style="color: black;"> 的返回值。 另一个例子是 </span><span style="color: black;"><span style="color: black;">sys.float_info</span></span><span style="color: black;">:&gt;&gt;&gt;&gt;&gt;&gt; sys.float_info # indexed access 1024 &gt;&gt;&gt; sys.float_info.max_exp # named field access 1024 &gt;&gt;&gt; isinstance(sys.float_info, tuple) # kind of tuple True有些具名元组是内置类型(例如上面的例子)。 <span style="color: black;">另外</span>,具名元组还可<span style="color: black;">经过</span>常规类定义从</span><span style="color: black;"><span style="color: black;">tuple</span></span><span style="color: black;"> 继承并定义名<span style="color: black;">叫作</span>字段的方式来创建。 <span style="color: black;">这般</span>的类<span style="color: black;">能够</span>手工编写,<span style="color: black;">或</span><span style="color: black;">运用</span>工厂函数 </span><span style="color: black;"><span style="color: black;">collections.namedtuple()</span></span><span style="color: black;"> 创建。 后一种方式还会添加<span style="color: black;">有些</span>手工编写或内置具名元组所<span style="color: black;">无</span>的额外<span style="color: black;">办法</span>。</span>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/dfic-imagehandler/46b9abe8-3471-4958-9ed9-2825ff547d11~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1723899621&amp;x-signature=4S0SG469cEEIBvU%2FJXSAUMOlpcg%3D" style="width: 50%; margin-bottom: 20px;"></div><span style="color: black;">namespace -- 命名空间命名空间是存放变量的场所。命名空间有局部、全局和内置的,还有对象中的嵌套命名空间(在<span style="color: black;">办法</span>之内)。命名空间<span style="color: black;">经过</span>防止命名冲突来支持模块化。例如,函数</span><span style="color: black;"><span style="color: black;">builtins.open</span></span><span style="color: black;"> 与 </span><span style="color: black;"><span style="color: black;">os.open()</span></span><span style="color: black;"> 可<span style="color: black;">经过</span>各自的命名空间来区分。命名空间还<span style="color: black;">经过</span><span style="color: black;">知道</span>哪个模块实现</span><span style="color: black;">那个</span><span style="color: black;">函数来<span style="color: black;">帮忙</span><span style="color: black;">加强</span>可读性和可<span style="color: black;">守护</span>性。例如,</span><span style="color: black;"><span style="color: black;">random.seed()</span></span><span style="color: black;"> 或 </span><span style="color: black;"><span style="color: black;">itertools.islice()</span></span><span style="color: black;"> 这种写法<span style="color: black;">知道</span>了这些函数<span style="color: black;">是由于</span> </span><span style="color: black;"><span style="color: black;">random</span></span><span style="color: black;"> 与 </span><span style="color: black;"><span style="color: black;">itertools</span></span><span style="color: black;"> 模块分别实现的。</span><span style="color: black;">namespace package -- 命名空间包</span><strong style="color: blue;"><span style="color: black;">PEP 420</span></strong><span style="color: black;">所引入的一种仅被用作子包的容器的 package,命名空间包<span style="color: black;">能够</span><span style="color: black;">无</span>实体<span style="color: black;">暗示</span>物,其描述方式与 regular package <span style="color: black;">区别</span>,因为它们<span style="color: black;">无</span> __init__.py 文件。另可参见 module。</span><span style="color: black;">nested scope -- 嵌套<span style="color: black;">功效</span>域在一个定义范围内引用变量的能力。例如,在另一函数之内定义的函数<span style="color: black;">能够</span>引用前者的变量。请<span style="color: black;">重视</span>嵌套<span style="color: black;">功效</span>域默认只对引用有效而对赋值无效。局部变量的读写都受限于最内层<span style="color: black;">功效</span>域。类似的,全局变量的读写则<span style="color: black;">功效</span>于全局命名空间。<span style="color: black;">经过</span></span><span style="color: black;"><span style="color: black;">nonlocal</span></span><span style="color: black;"> 关键字可<span style="color: black;">准许</span>写入外层<span style="color: black;">功效</span>域。</span><span style="color: black;">new-style class -- 新式类<span style="color: black;">针对</span><span style="color: black;">日前</span>已被应于所有类对象的类形式的旧<span style="color: black;">叫作</span>谓。在早先的 Python 版本中,<span style="color: black;">仅有</span>新式类能够<span style="color: black;">运用</span> Python 新增的更灵活特性,例如 </span><span style="color: black;"><span style="color: black;">__slots__</span></span><span style="color: black;">、描述符、特征属性、</span><span style="color: black;"><span style="color: black;">__getattribute__()</span></span><span style="color: black;">、类<span style="color: black;">办法</span>和静态<span style="color: black;">办法</span>等。</span><span style="color: black;">object -- 对象任何<span style="color: black;">拥有</span>状态(属性或值)以及预定义<span style="color: black;">行径</span>(<span style="color: black;">办法</span>)的数据。object <span style="color: black;">亦</span>是任何 new-style class 的最顶层基类名。</span><span style="color: black;">package -- 包一种可<span style="color: black;">包括</span>子模块或递归地<span style="color: black;">包括</span>子包的 Python module。从技术上说,包是带有 __path__ 属性的 Python 模块。另参见 regular package 和 namespace package。</span><span style="color: black;">parameter -- 形参function (或<span style="color: black;">办法</span>)定义中的命名实体,它指定函数<span style="color: black;">能够</span>接受的一个 argument (或在某些<span style="color: black;">状况</span>下,多个实参)。有五种形参:</span><span style="color: black;">positional-or-keyword</span><span style="color: black;">:位置或关键字,指定一个<span style="color: black;">能够</span><span style="color: black;">做为</span> 位置参数 传入<span style="color: black;">亦</span><span style="color: black;">能够</span><span style="color: black;">做为</span> 关键字参数 传入的实参。这是默认的形参类型,例如下面的 </span><span style="color: black;">foo</span><span style="color: black;"> 和 </span><span style="color: black;">bar</span><span style="color: black;">:def func(foo, bar=None): ...</span><span style="color: black;">positional-only</span><span style="color: black;">:仅限位置,指定一个只能<span style="color: black;">经过</span>位置传入的参数。 仅限位置形参可<span style="color: black;">经过</span>在函数定义的形参列表中它们之后<span style="color: black;">包括</span>一个 / 字符来定义,例如下面的</span><span style="color: black;">posonly1</span><span style="color: black;"> 和 </span><span style="color: black;">posonly2</span><span style="color: black;">:def func(posonly1, posonly2, /, positional_or_keyword): ...</span><span style="color: black;">keyword-only</span><span style="color: black;">:仅限关键字,指定一个只能<span style="color: black;">经过</span>关键字传入的参数。仅限关键字形参可<span style="color: black;">经过</span>在函数定义的形参列表中<span style="color: black;">包括</span>单个可变位置形参<span style="color: black;">或</span>在多个可变位置形参之前放一个 * 来定义,例如下面的</span><span style="color: black;">kw_only1</span><span style="color: black;"> 和 </span><span style="color: black;">kw_only2</span><span style="color: black;">:def func(arg, *, kw_only1, kw_only2): ...</span><span style="color: black;">var-positional</span><span style="color: black;">:可变位置,指定<span style="color: black;">能够</span><span style="color: black;">供给</span>由一个任意数量的位置参数<span style="color: black;">形成</span>的序列(附加在其他形参已接受的位置参数之后)。这种形参可<span style="color: black;">经过</span>在形参名<span style="color: black;">叫作</span>前加缀 * 来定义,例如下面的</span><span style="color: black;">args</span><span style="color: black;">:def func(*args, **kwargs): ...</span><span style="color: black;">var-keyword</span><span style="color: black;">:可变关键字,指定<span style="color: black;">能够</span><span style="color: black;">供给</span>任意数量的关键字参数(附加在其他形参已接受的关键字参数之后)。这种形参可<span style="color: black;">经过</span>在形参名<span style="color: black;">叫作</span>前加缀 ** 来定义,例如上面的</span><span style="color: black;">kwargs</span><span style="color: black;">。形参<span style="color: black;">能够</span><span style="color: black;">同期</span>指定可选和必选参数,<span style="color: black;">亦</span><span style="color: black;">能够</span>为某些可选参数指定默认值。另参见 argument 术语表条目、参数与形参的区别 中的<span style="color: black;">平常</span>问题、</span><span style="color: black;"><span style="color: black;">inspect.Parameter</span></span><span style="color: black;"> 类、函数定义一节以及 </span><strong style="color: blue;"><span style="color: black;">PEP 362</span></strong><span style="color: black;">。</span><span style="color: black;">path entry -- 路径入口import path 中的一个单独位置,会被 path based finder 用来<span style="color: black;">查询</span>要导入的模块。</span>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p26-sign.toutiaoimg.com/dfic-imagehandler/bcb04148-2379-466d-b585-f6d92306703e~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1723899621&amp;x-signature=c5sVv7DasDmpXrqukQAgJCGdqQw%3D" style="width: 50%; margin-bottom: 20px;"></div><span style="color: black;">path entry finder -- 路径入口<span style="color: black;">查询</span>器任一可调用对象<span style="color: black;">运用</span> </span><span style="color: black;"><span style="color: black;">sys.path_hooks</span></span><span style="color: black;">(即 path entry hook) 返回的 finder,此种对象能<span style="color: black;">经过</span> path entry 来定位模块。请参看</span><span style="color: black;"><span style="color: black;">importlib.abc.PathEntryFinder</span></span><span style="color: black;"> 以<span style="color: black;">认识</span>路径入口<span style="color: black;">查询</span>器所实现的各个<span style="color: black;">办法</span>。</span><span style="color: black;">path entry hook -- 路径入口钩子一种可调用对象,在<span style="color: black;">晓得</span><span style="color: black;">怎样</span><span style="color: black;">查询</span>特定 path entry 中的模块的<span style="color: black;">状况</span>下能够<span style="color: black;">运用</span> sys.path_hook 列表返回一个 path entry finder。</span><span style="color: black;">path based finder -- 基于路径的<span style="color: black;">查询</span>器默认的一种 元路径<span style="color: black;">查询</span>器,可在一个 import path 中<span style="color: black;">查询</span>模块。</span><span style="color: black;">path-like object -- 路径类对象<span style="color: black;">表率</span>一个文件系统路径的对象。类路径对象<span style="color: black;">能够</span>是一个<span style="color: black;">暗示</span>路径的 </span><span style="color: black;"><span style="color: black;">str</span></span><span style="color: black;"> <span style="color: black;">或</span> </span><span style="color: black;"><span style="color: black;">bytes</span></span><span style="color: black;">对象,还<span style="color: black;">能够</span>是一个实现了</span><span style="color: black;"><span style="color: black;">os.PathLike</span></span><span style="color: black;"> 协议的对象。一个支持 </span><span style="color: black;"><span style="color: black;">os.PathLike</span></span><span style="color: black;"> 协议的对象可<span style="color: black;">经过</span>调用 </span><span style="color: black;"><span style="color: black;">os.fspath()</span></span><span style="color: black;"> 函数转换为 </span><span style="color: black;"><span style="color: black;">str</span></span><span style="color: black;"> <span style="color: black;">或</span> </span><span style="color: black;"><span style="color: black;">bytes</span></span><span style="color: black;"> 类型的文件系统路径;</span><span style="color: black;"><span style="color: black;">os.fsdecode()</span></span><span style="color: black;"> 和 </span><span style="color: black;"><span style="color: black;">os.fsencode()</span></span><span style="color: black;"> 可被分别用来<span style="color: black;">保证</span><span style="color: black;">得到</span> </span><span style="color: black;"><span style="color: black;">str</span></span><span style="color: black;"> 或 </span><span style="color: black;"><span style="color: black;">bytes</span></span><span style="color: black;"> 类型的结果。此对象<span style="color: black;">是由于</span> </span><strong style="color: blue;"><span style="color: black;">PEP 519</span></strong><span style="color: black;"> 引入的。</span><span style="color: black;">PEP“Python <span style="color: black;">加强</span>提议”的英文缩写。一个 PEP <span style="color: black;">便是</span>一份设计文档,用来向 Python 社区<span style="color: black;">供给</span>信息,或描述一个 Python 的新增特性及其进度或环境。PEP 应当<span style="color: black;">供给</span>精确的技术规格和所提议特性的原理说明。PEP 应被<span style="color: black;">做为</span>提出<span style="color: black;">重点</span>新特性<span style="color: black;">意见</span>、收集社区对特定问题反馈以及为<span style="color: black;">必要</span>加入 Python 的设计决策编写文档的首选机制。PEP 的作者有责任在社区内部<span style="color: black;">创立</span>共识,并应将<span style="color: black;">区别</span>意见<span style="color: black;">亦</span>记入文档。参见</span><strong style="color: blue;"><span style="color: black;">PEP 1</span></strong><span style="color: black;">。</span><span style="color: black;">portion -- 部分<span style="color: black;">形成</span>一个命名空间包的单个目录内文件集合(<span style="color: black;">亦</span>可能存放于一个 zip 文件内),<span style="color: black;">详细</span>定义见 </span><strong style="color: blue;"><span style="color: black;">PEP 420</span></strong><span style="color: black;">。</span><span style="color: black;">positional argument -- 位置参数参见 argument。</span><span style="color: black;">provisional API -- 暂定 API暂定 API <span style="color: black;">指的是</span>被有意排除在标准库的向后兼容性<span style="color: black;">保准</span>之外的应用编程接口。虽然此类接口<span style="color: black;">一般</span>不会再有重大改变,但只要其被标记为暂定,就可能在核心<span style="color: black;">研发</span>者确定有必要的<span style="color: black;">状况</span>下进行向后不兼容的更改(<span style="color: black;">乃至</span><span style="color: black;">包含</span>移除该接口)。此种更改并不会随意进行 -- 仅在 API 被加入之前未<span style="color: black;">思虑</span>到的严重<span style="color: black;">基本</span>性缺陷被<span style="color: black;">发掘</span>时才可能会<span style="color: black;">这般</span>做。即便是对暂定 API <span style="color: black;">来讲</span>,向后不兼容的更改<span style="color: black;">亦</span>会被视为“最后的<span style="color: black;">处理</span><span style="color: black;">方法</span>” —— 任何问题被确认时都会尽可能先尝试找到一种向后兼容的<span style="color: black;">处理</span><span style="color: black;">方法</span>。这种处理过程<span style="color: black;">准许</span>标准库<span style="color: black;">连续</span><span style="color: black;">持续</span>地演进,不至于被有问题的<span style="color: black;">长时间</span>性设计缺陷所困。详情见</span><strong style="color: blue;"><span style="color: black;">PEP 411</span></strong><span style="color: black;">。</span><span style="color: black;">provisional package -- 暂定包参见 provisional API。</span><span style="color: black;">Python 3000Python 3.x 发布路线的昵<span style="color: black;">叫作</span>(这个名字在版本 3 的发布还遥遥无期的时候就已<span style="color: black;">显现</span>了)。有时<span style="color: black;">亦</span>被缩写为“Py3k”。</span><span style="color: black;">Pythonic</span><span style="color: black;">指</span><span style="color: black;">一个思路或一段代码紧密遵循了 Python 语言最常用的风格和理念,而不是<span style="color: black;">运用</span>其他语言中通用的概念来实现代码。例如,Python 的常用风格是<span style="color: black;">运用</span></span><span style="color: black;"><span style="color: black;">for</span></span><span style="color: black;">语句循环来遍历一个可迭代对象中的所有元素。许多其他语言<span style="color: black;">无</span><span style="color: black;">这般</span>的结构,<span style="color: black;">因此呢</span>不<span style="color: black;">熟练</span> Python 的人有时会<span style="color: black;">选取</span><span style="color: black;">运用</span>一个数字计数器:for i in range(len(food)): print(food)而相应的更简洁更 Pythonic 的<span style="color: black;">办法</span>是<span style="color: black;">这般</span>的:for piece in food: print(piece)</span><span style="color: black;">qualified name -- 限定名<span style="color: black;">叫作</span>一个以点号分隔的名<span style="color: black;">叫作</span>,<span style="color: black;">表示</span>从模块的全局<span style="color: black;">功效</span>域到该模块中定义的某个类、函数或<span style="color: black;">办法</span>的“路径”,<span style="color: black;">关联</span>定义见</span><strong style="color: blue;"><span style="color: black;">PEP 3155</span></strong><span style="color: black;">。<span style="color: black;">针对</span>最高层级的函数和类,限定名<span style="color: black;">叫作</span>与对象名<span style="color: black;">叫作</span>一致:&gt;&gt;&gt;&gt;&gt;&gt; class C: ... class D: ... def meth(self): ... pass ... &gt;&gt;&gt; C.__qualname__ C &gt;&gt;&gt; C.D.__qualname__ C.D &gt;&gt;&gt; C.D.meth.__qualname__ C.D.meth当被用于引用模块时,</span><span style="color: black;">完整限定名<span style="color: black;">叫作</span></span><span style="color: black;">意为标示该模块的以点号分隔的<span style="color: black;">全部</span>路径,其中<span style="color: black;">包括</span>其所有的父包,例如 email.mime.text:&gt;&gt;&gt;&gt;&gt;&gt; import email.mime.text &gt;&gt;&gt; email.mime.text.__name__ email.mime.text</span>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/dfic-imagehandler/bf7601ab-0bec-4e9a-8ac1-1bfc481f6a75~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1723899621&amp;x-signature=LReaoY45Fj%2F%2BHu4rs23h35zeUs4%3D" style="width: 50%; margin-bottom: 20px;"></div><span style="color: black;">reference count -- 引用计数对特定对象的引用的数量。当一个对象的引用计数降为零时,所分配资源将被释放。引用计数对 Python 代码<span style="color: black;">来讲</span><span style="color: black;">一般</span>是不可见的,但它是 CPython 实现的一个关键元素。</span><span style="color: black;"><span style="color: black;">sys</span></span><span style="color: black;"> 模块定义了一个 </span><span style="color: black;"><span style="color: black;">getrefcount()</span></span><span style="color: black;">函数,程序员可调用它来返回特定对象的引用计数。</span><span style="color: black;">regular package -- 常规包传统型的 package,例如<span style="color: black;">包括</span>有一个 __init__.py 文件的目录。另参见 namespace package。</span><strong style="color: blue;"><span style="color: black;">slots</span></strong><span style="color: black;">一种写在类内部的声明,<span style="color: black;">经过</span>预先声明实例属性等对象并移除实例字典来节省内存。虽然这种技巧很流行,但想要用好却并<span style="color: black;">不易</span>,最好是只<span style="color: black;">保存</span>在<span style="color: black;">少许</span><span style="color: black;">状况</span>下采用,例如极耗内存的应用程序,并且其中<span style="color: black;">包括</span><span style="color: black;">海量</span>实例。</span><span style="color: black;">sequence -- 序列一种 iterable,它支持<span style="color: black;">经过</span> </span><span style="color: black;"><span style="color: black;">__getitem__()</span></span><span style="color: black;"> 特殊<span style="color: black;">办法</span>来<span style="color: black;">运用</span>整数索引进行<span style="color: black;">有效</span>的元素<span style="color: black;">拜访</span>,并定义了一个返回序列长度的 </span><span style="color: black;"><span style="color: black;">__len__()</span></span><span style="color: black;"><span style="color: black;">办法</span>。内置的序列类型有</span><span style="color: black;"><span style="color: black;">list</span></span><span style="color: black;">、</span><span style="color: black;"><span style="color: black;">str</span></span><span style="color: black;">、</span><span style="color: black;"><span style="color: black;">tuple</span></span><span style="color: black;"> 和 </span><span style="color: black;"><span style="color: black;">bytes</span></span><span style="color: black;">。<span style="color: black;">重视</span>虽然 </span><span style="color: black;"><span style="color: black;">dict</span></span><span style="color: black;"> <span style="color: black;">亦</span>支持 </span><span style="color: black;"><span style="color: black;">__getitem__()</span></span><span style="color: black;"> 和 </span><span style="color: black;"><span style="color: black;">__len__()</span></span><span style="color: black;">,但它被认为属于映射而非序列,<span style="color: black;">由于</span>它<span style="color: black;">查询</span>时<span style="color: black;">运用</span>任意的 immutable 键而非整数。</span><span style="color: black;"><span style="color: black;">collections.abc.Sequence</span></span><span style="color: black;"> 抽象基类定义了一个更丰富的接口,它在 </span><span style="color: black;"><span style="color: black;">__getitem__()</span></span><span style="color: black;"> 和 </span><span style="color: black;"><span style="color: black;">__len__()</span></span><span style="color: black;"> 之外又添加了 count(), index(), </span><span style="color: black;"><span style="color: black;">__contains__()</span></span><span style="color: black;"> 和 </span><span style="color: black;"><span style="color: black;">__reversed__()</span></span><span style="color: black;">。 实现此扩展接口的类型<span style="color: black;">能够</span><span style="color: black;">运用</span> </span><span style="color: black;"><span style="color: black;">register()</span></span><span style="color: black;"> 来显式地注册。</span><span style="color: black;">set comprehension -- 集合推导式处理一个可迭代对象中的所有或部分元素并返回结果集合的一种紧凑写法。 results = {c for c in abracadabra if c not in abc} 将生成字符串集合 {r, d}。 参见 列表、集合与字典的<span style="color: black;">表示</span>。</span><span style="color: black;">single dispatch -- 单分派一种 generic function 分派形式,其实现是基于单个参数的类型来<span style="color: black;">选取</span>的。</span><span style="color: black;">slice -- 切片<span style="color: black;">一般</span>只<span style="color: black;">包括</span>了特定 sequence 的一部分的对象。切片是<span style="color: black;">经过</span><span style="color: black;">运用</span>下标标记来创建的,在 [] 中给出几个以冒号分隔的数字,例如 variable_name。方括号(下标)标记在内部<span style="color: black;">运用</span> </span><span style="color: black;"><span style="color: black;">slice</span></span><span style="color: black;"> 对象。</span><span style="color: black;">special method -- 特殊<span style="color: black;">办法</span>一种由 Python 隐式调用的<span style="color: black;">办法</span>,用来对某个类型执行特定操作例如相加等等。这种<span style="color: black;">办法</span>的名<span style="color: black;">叫作</span>的首尾都为双下划线。特殊<span style="color: black;">办法</span>的文档参见 特殊<span style="color: black;">办法</span>名<span style="color: black;">叫作</span>。</span><span style="color: black;">statement -- 语句语句是程序段(一个代码“块”)的<span style="color: black;">构成</span>单位。一条语句<span style="color: black;">能够</span>是一个 expression 或某个带<span style="color: black;">相关</span>键字的结构,例如 </span><span style="color: black;"><span style="color: black;">if</span></span><span style="color: black;">、</span><span style="color: black;"><span style="color: black;">while</span></span><span style="color: black;"> 或 </span><span style="color: black;"><span style="color: black;">for</span></span><span style="color: black;">。</span><span style="color: black;">text encoding -- 文本编码用于将Unicode字符串编码为字节串的编码器。</span><span style="color: black;">text file -- 文本文件一种能够读写 </span><span style="color: black;"><span style="color: black;">str</span></span><span style="color: black;">对象的 file object。<span style="color: black;">一般</span>一个文本文件<span style="color: black;">实质</span>是<span style="color: black;">拜访</span>一个面向字节的数据流并自动处理 text encoding。文本文件的例子<span style="color: black;">包含</span>以文本模式(r 或 w)打开的文件、</span><span style="color: black;"><span style="color: black;">sys.stdin</span></span><span style="color: black;">、</span><span style="color: black;"><span style="color: black;">sys.stdout</span></span><span style="color: black;"> 以及 </span><span style="color: black;"><span style="color: black;">io.StringIO</span></span><span style="color: black;"> 的实例。另请参看 binary file <span style="color: black;">认识</span>能够读写 字节类对象 的文件对象。</span><span style="color: black;">triple-quoted string -- 三引号字符串首尾各带三个连续双引号(")<span style="color: black;">或</span>单引号()的字符串。它们在功能上与首尾各用一个引号标注的字符串<span style="color: black;">无</span>什么<span style="color: black;">区别</span>,<span style="color: black;">然则</span>有多种用处。它们<span style="color: black;">准许</span>你在字符串内<span style="color: black;">包括</span>未经转义的单引号和双引号,并且<span style="color: black;">能够</span>跨越多行而无需<span style="color: black;">运用</span>连接符,在编写文档字符串时<span style="color: black;">尤其</span>好用。</span><span style="color: black;">type -- 类型类型决定一个 Python 对象属于什么种类;<span style="color: black;">每一个</span>对象都<span style="color: black;">拥有</span>一种类型。要<span style="color: black;">晓得</span>对象的类型,<span style="color: black;">能够</span><span style="color: black;">拜访</span>它的 </span><span style="color: black;"><span style="color: black;">__class__</span></span><span style="color: black;"> 属性,或是<span style="color: black;">经过</span> type(obj) 来获取。</span>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/dfic-imagehandler/7fcce7c5-0915-4df6-a764-5ac2d79d47a5~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1723899621&amp;x-signature=02yREnlhWTgAWoqeP62kwxnnkLo%3D" style="width: 50%; margin-bottom: 20px;"></div><span style="color: black;">type alias -- 类型别名一个类型的同义词,创建方式是把类型赋值给特定的标识符。类型别名的<span style="color: black;">功效</span>是简化 类型提示。例如:from typing import List, Tuple def remove_gray_shades( colors: List]) -&gt; List]: pass<span style="color: black;">能够</span><span style="color: black;">这般</span><span style="color: black;">加强</span>可读性:from typing import List, Tuple Color = Tuple def remove_gray_shades(colors: List) -&gt; List: pass参见</span><span style="color: black;"><span style="color: black;">typing</span></span><span style="color: black;"> 和 </span><strong style="color: blue;"><span style="color: black;">PEP 484</span></strong><span style="color: black;">,其中有对此功能的<span style="color: black;">仔细</span>描述。</span><span style="color: black;">type hint -- 类型提示annotation 为变量、类属性、函数的形参或返回值指定预期的类型。类型提示属于可选项,Python 不<span style="color: black;">需求</span><span style="color: black;">供给</span>,但其可对静态类型分析工具起<span style="color: black;">功效</span>,并可<span style="color: black;">帮助</span> IDE 实现代码补全与重构。全局变量、类属性和函数的类型提示<span style="color: black;">能够</span><span style="color: black;">运用</span></span><span style="color: black;"><span style="color: black;">typing.get_type_hints()</span></span><span style="color: black;"> 来<span style="color: black;">拜访</span>,但局部变量则不<span style="color: black;">能够</span>。参见 </span><span style="color: black;"><span style="color: black;">typing</span></span><span style="color: black;"> 和 </span><strong style="color: blue;"><span style="color: black;">PEP 484</span></strong><span style="color: black;">,其中有对此功能的<span style="color: black;">仔细</span>描述。</span><span style="color: black;">universal newlines -- 通用换行一种<span style="color: black;">诠释</span>文本流的方式,将以下所有符号都识别为行结束标志:Unix 的行结束约定 \n、Windows 的约定 \r\n 以及旧版 Macintosh 的约定 \r。参见</span><strong style="color: blue;"><span style="color: black;">PEP 278</span></strong><span style="color: black;"> 和 </span><strong style="color: blue;"><span style="color: black;">PEP 3116</span></strong><span style="color: black;"> 和 </span><span style="color: black;"><span style="color: black;">bytes.splitlines()</span></span><span style="color: black;"> <span style="color: black;">认识</span><span style="color: black;">更加多</span>用法说明。</span><span style="color: black;">variable annotation -- 变量标注对变量或类属性的 annotation。在标注变量或类属性时,还可<span style="color: black;">选取</span>为其赋值:class C: field: annotation变量标注<span style="color: black;">一般</span>被用作 类型提示:例如以下变量预期接受</span><span style="color: black;"><span style="color: black;">int</span></span><span style="color: black;">类型的值:count: int = 0变量标注语法的<span style="color: black;">仔细</span>解释见 带标注的赋值语句 一节。请参看 function annotation、</span><strong style="color: blue;"><span style="color: black;">PEP 484</span></strong><span style="color: black;"> 和 </span><strong style="color: blue;"><span style="color: black;">PEP 526</span></strong><span style="color: black;">,其中对此功能有<span style="color: black;">仔细</span>描述。</span><span style="color: black;">virtual environment -- 虚拟环境一种采用协作式隔离的运行时环境,<span style="color: black;">准许</span> Python 用户和应用程序在安装和升级 Python 分发包时不会干扰到同一系统上运行的其他 Python 应用程序的<span style="color: black;">行径</span>。另参见</span><span style="color: black;"><span style="color: black;">venv</span></span><span style="color: black;">。</span><span style="color: black;">virtual machine -- 虚拟机一台完全<span style="color: black;">经过</span>软件定义的计算机。Python 虚拟机可执行字节码编译器所生成的 bytecode。</span><span style="color: black;">Zen of Python -- Python </span><span style="color: black;">之禅</span><span style="color: black;">列出 Python 设计的原则与哲学,有助于理解与<span style="color: black;">运用</span>这种语言。查看其<span style="color: black;">详细</span>内容可在交互模式提示符中输入 "import this"。</span>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/e067f61ab71f4a509998de01982e0c04~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1723899621&amp;x-signature=n9kF%2BtA62yj5rdCUj9RLsRepxUo%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">最后,<span style="color: black;">博主</span>想说:我是一名python<span style="color: black;">研发</span>工程师,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">整理了一套最新的python系统学习教程,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">想要这些资料的<span style="color: black;">能够</span>关注私信<span style="color: black;">博主</span>“01”<span style="color: black;">就可</span>(免费分享哦)<span style="color: black;">期盼</span>能对你有所<span style="color: black;">帮忙</span>.</p>




情迷布拉格 发表于 2024-8-22 22:37:47

一看到楼主的气势,我就觉得楼主同在社区里灌水。

听听海 发表于 2024-8-31 07:34:34

楼主听话,多发外链好处多,快到碗里来!外链论坛 http://www.fok120.com/

wrjc1hod 发表于 2024-10-2 13:10:45

我深受你的启发,你的话语是我前进的动力。
页: [1]
查看完整版本: Python术语对照表(下)