1.1 默默无闻的省略号很好用 ========================== .. image:: http://image.iswbm.com/20200804124133.png 在Python中,一切皆对象,省略号也不例外。 在 Python 3 中你可以直接写 ``...`` 来得到它 .. code:: python >>> ... Ellipsis >>> type(...) 而在 Python 2 中没有\ ``...`` 这个语法,只能直接写Ellipsis来获取。 .. code:: python >>> Ellipsis Ellipsis >>> type(Ellipsis) >>> 它转为布尔值时为真 .. code:: python >>> bool(...) True 最后,这东西是一个单例。 .. code:: python >>> id(...) 4362672336 >>> id(...) 4362672336 那这东西有啥用呢? 1. 它是 Numpy 的一个语法糖 2. 在 Python 3 中可以使用 … 代替 pass .. code:: shell $ cat demo.py def func01(): ... def func02(): pass func01() func02() print("ok") $ python3 demo.py ok