gpt4 book ai didi

python - 是什么意思?它有意义吗?

转载 作者:太空宇宙 更新时间:2023-11-03 13:02:01 25 4
gpt4 key购买 nike

我有时看到但不理解 ... 的含义。三个时期。下面是我不明白的例子:

>>> t = 12345, 54321, 'hello!'
>>> t[0]
12345
>>> t
(12345, 54321, 'hello!')
>>> # Tuples may be nested:
... u = t, (1, 2, 3, 4, 5)
>>> u
((12345, 54321, 'hello!'), (1, 2, 3, 4, 5))

这三个时期在u面前干什么?

最佳答案

在您的情况下,这主要是为了表明您正在继续执行同一代码块。然而,在 Python 中有一个 Ellipsis 对象主要用于 numpy 数组,但在 Python3.x 中,它也可用作 ...,所以在 Python3.x 解释器中输入它会返回 Ellipsis...

作为行/ block 的延续:

>>> if 3 > 2:
... print 'yes' # indicates we're inside another block or continuing a statement

作为省略号(在 Python 3.x 中):

Python 3.3.0 (default, Sep 29 2012, 17:14:58) 
[GCC 4.7.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> ...
Ellipsis

关于python - 是什么意思?它有意义吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17146320/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com