Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有人可以解释一下吗?
>>> x=x[0]=[0] >>> x [[...]] >>> x is x[0] True >>> x[0][0][0][0][0][0][0] [[...]] >>> x in x True
什么是 [...]?
那只是 Python 告诉你你有一个循环引用;它足够聪明,不会进入试图打印出来的无限循环。
它由负责生成结构表示的方法输出。它代表一个递归结构,因为它可以无限嵌套,所以被省略。
iPython 会这样做:
[<Recursion on list with id=38505216>]
这是同一件事; 解释器告诉你你有一个递归数据结构。