小编Ash*_*amu的帖子

Python 中的省略号有什么用?

有人可以帮忙吗,Python 中 Ellipse 的用途是什么,并提供一些示例以及何时使用它?

我对此进行了一些搜索,它可以与函数一起使用:

 def add():
     ...
Run Code Online (Sandbox Code Playgroud)

并在列表中进行切片。

import numpy
n = numpy.arange(16).reshape(2, 2, 2, 2)

print(n)

print('----------------')
print(n[1,...,1])

[[[[ 0  1]
   [ 2  3]]

  [[ 4  5]
   [ 6  7]]]


 [[[ 8  9]
   [10 11]]

  [[12 13]
   [14 15]]]]
----------------
Ellipsis:[[ 9 11]
 [13 15]]
Run Code Online (Sandbox Code Playgroud)

python ellipse python-3.x

4
推荐指数
1
解决办法
5391
查看次数

标签 统计

ellipse ×1

python ×1

python-3.x ×1