Python编程术语词汇表(一)

liftword2个月前 (03-16)技术文章7

这是一个非官方的 Python 编程术语表,是日常编程实践以及网络收藏所得的内容集合。

Iteration 迭代

Looping over an iterable object.
遍历可迭代对象。

A for loop is the epitome of iteration, but there are many other ways to iterate over an iterable in Python.
一个
for 循环是迭代的典范,但在 Python 中还有许多其他方法可以遍历可迭代对象。

Iterable 可迭代

(Our perspective as Python users) Anything you can loop over with a for loop or by various other forms of iteration. More on iterables in What is an iterable.
(作为 Python 用户的我们) 你可以用 for 循环或通过其他各种迭代形式遍历的任何内容。关于可迭代对象的更多信息,请参阅什么是可迭代对象。

(Python's perspective) Anything that can be passed to the built-in iter function to get an iterator from it. If you're inventing your own iterable class, also see How to make an iterable.
(Python 视角)任何可以被传递给内置的 iter 函数以从中获取迭代器的对象。如果你正在创建自己的可迭代类,也请参阅如何创建可迭代对象。

String 字符串

Strings are a data type used for storing text. Strings are made up of characters, which may be letters, numbers, symbols, whitespace, emoji, etc.
字符串是用于存储文本的数据类型。字符串由字符组成,可以是字母、数字、符号、空白、表情符号等。

Substring 子字符串

A "substring" is a string that is contained within another string.
一个“子字符串”是包含在另一个字符串中的字符串。

As an example, "tho" is a substring of "Python".
例如, "tho""Python" 的子串。

Boolean 布尔

Python's two Boolean values are True and False. These values both have the type of bool, which stands for Boolean (named after George Boole, in case you're curious).
Python 的两个布尔值是 TrueFalse 。这两个值都具有 bool 类型,代表布尔(如果你好奇,这个名字是为了纪念乔治·布尔)。

Integer (a.k.a. int) 整数(又称 int )

Integers are used for representing whole numbers in Python. The numbers 5, 0, and -2 are examples of integers.
整数用于在 Python 中表示整数。数字 5 、0 和 -2 是整数的例子。

Floating Point Numbers (a.k.a. float)
浮点数(又称 float )

Floating point numbers are used for representing non-integers. The numbers 5.0, 2.5, and -3.4 are examples of floating point numbers.
浮点数用于表示非整数。数字 5.02.5-3.4 是浮点数的示例。

Floating point numbers may be equivalent to integers. For example, 5.0 is equal to 5 in Python: 5.0 == 5 returns True.
浮点数可能与整数等价。例如,在 Python 中 5.0 等于 55.0 == 5 返回 True

Index 索引

An integer that represents the position of an item within a list or another sequence.
一个表示列表或另一个序列中项目位置的整数。

Sequences in Python use zero-based indexes, so the first item is at position 0.
Python 中的序列使用零基索引,因此第一个元素位于位置 0

Sequence (a.k.a. "list-like object")
序列(又称“类似列表的对象”)

An ordered collection of objects. Sequences have a length (via the built-in len function), can be indexed (starting at 0), and are iterable.
一个有序的对象集合。序列具有长度(通过内置的 len 函数),可以索引(从 0 开始),并且是可迭代的。

Mapping 映射

A dictionary-like object. An object which stores key-value pairs and supports key lookups using square brackets ([...]), among other features we expect dictionary-like objects to support (such as being an iterable). Like sequences, mappings are iterable.
一个类似字典的对象。一个存储键值对并支持使用方括号( [ ... ] )进行键查找的对象,以及其他我们期望类似字典对象支持的功能(如可迭代)。像序列一样,映射是可迭代的。

Tuple 元组

An immutable sequence. Tuples act like a list, but they can't be mutated. While tuples could just be thought of as immutable lists, we usually use the two quite differently: tuples are for storing a fixed number of values, often of different types.
一个不可变序列。元组的行为类似于列表,但不能被修改。虽然元组可以简单地被视为不可变列表,但我们通常使用它们的方式相当不同:元组用于存储固定数量的值,通常是不同类型的值。

List Comprehension 列表推导

A special syntax for building a new list/set/dictionary out of an old iterable. Comprehensions build a new iterable out of an old one while either filtering items down based on a condition or modifying each item based on a mapping expression.
特殊语法,用于从旧的可迭代对象中构建新的列表/集合/字典。列表推导从旧的可迭代对象中构建新的可迭代对象,同时根据条件过滤项目或根据映射表达式修改每个项目。

Truthiness 真实性

Truthiness asks the question "if we convert this object to a Boolean, will we get True or False?"
真实性询问问题:“如果我们将此对象转换为布尔值,我们会得到 True 还是 False ?”

Containment 隔离

Python's in operator checks for "containment": x in y means y "contains" x. All iterables support containment by default, but some objects customize containment checks to make them faster (dictionary containment) or to operate slightly differently (substring checks).
Python 的 in 运算符检查“包含”: x in y 表示 y “包含” x 。所有可迭代对象默认支持包含,但某些对象自定义包含检查以使其更快(字典包含)或略有不同(子字符串检查)。

Lexicographical ordering 词典顺序

Strings, tuples, and lists in Python are ordered "lexicographically".
Python 中的字符串、元组和列表是按“字典序”排序的。

Lexicographical ordering essentially means "similar to alphabetical ordering". For example, "animal" < "apple" is True because since the first letters are equivalent, the second letters are compared and "n" < "p" (in both Unicode and the alphabet). Likewise, (1969, 5, 18) < (1969, 7, 16) is True because since the first indexes are equivalent, the second indexes are compared and 5 < 7.
词序排列本质上意味着“类似于字母顺序”。例如, "animal" < "apple" 等于 True ,因为第一个字母相同,所以比较第二个字母(在 Unicode 和字母表中)。同样, (1969, 5, 18) < (1969, 7, 16) 等于 True ,因为第一个索引相同,所以比较第二个索引和 5 < 7

File-like Object 文件对象

A file-like object is an object that behaves like a file.
文件类对象是一种表现得像文件的对象。

Files are file-like objects, but so are the standard input (sys.stdin), standard output (sys.stdout), and standard error (sys.stderr) file streams. It's also possible to create your own file-like objects.
文件是类似文件的对象,但标准输入( sys.stdin )、标准输出( sys.stdout )和标准错误( sys.stderr )文件流也是如此。也可以创建自己的类似文件的对象。


如果你觉得这篇文章对你有帮助,欢迎点赞、收藏和转发!关注我,获取更多 Python 编程技巧和实用知识

#python##什么是deepseek##编程#

相关文章

Python6大基础运算符,看完这篇之后会让你有一个彻底认识

昨天我们准备好了Python程序所需要的的东西,那么今天我们开始了解Python的各种基础运算符,这些要是不熟悉下来你后面的路也会走的很艰难Python支持基础运算符,常见的算术运算符有+、-、*、/...

这 10 个Python 运算符,后悔没有早知道

新人求关注,博主天天日更,全年无休,您的关注是我的更新的功力~ 感谢 海象操作符 :=海象操作符可以执行两件事。在 x := 5 中:它将变量 x 赋值为 5。表达式 (x := 5) 会返回 x 本...

Python中的位运算符

Python中的位运算符与其它语言中的位运算符作用相同。位运算符也称二进制运算符,并且这些运算符只用于对整型数进行运算。进行位运算时,整型数被转换为二进制形式,然后位运算符对每位执行有关运算后,将结果...

Python中的运算符详解

当提到Python编程语言时,运算符是非常重要的概念。运算符是用于执行各种操作的特殊符号或符号组合。Python中的运算符用于执行各种算术、赋值、逻辑、比较和位运算。当我们有了数据,就可以通过运算符把...

Python增量运算符:初学者分步指南

不使用Python递增运算符递增变量先看看如何手动增加变量的值,而不使用+=。代码示例:count = 1 # Initializing count with 1 count = count + 2...

python 加、减、乘、除、乘方运算符

Python支持的所有基本算术运算符:所谓算术运算,是指初等数学中常见的计算,如加、减、乘、除、乘方等。Python 语言也y与数学中的运算一样。表中列出了 Python 实现算术运算所使用的运算符。...