python中的打印是什么意思_Python为对象引用打印“[…]”是什么意思?

我正在打印一个我认为是一个列表的值,但是我得到的输出是:[...]

这代表什么?我如何测试它?我试过:

^{pr2}$

以及myVar.__repr_() != Ellipsis

但是没有骰子。。。在

以下是导致问题的代码缩减:def buildPaths(graph, start, end, path=[], totalPaths=[]):

"""

returns list of all possible paths from start node to the end node

"""

path = path + [start]

if start == end:

return path

for nextNode in graph.childrenOf(start):

if nextNode not in path:

newPath = buildPaths(graph, nextNode, end, path, totalPaths)

if newPath != []: # test

totalPaths.append(newPath)

return totalPaths

totalPaths包含许多[…]本应是递归列表,但我不明白为什么。为了防止这种情况的发生,我改变了测试。在

我也试过:def buildPaths(graph, thisNode, end, path=[], totalPaths=None):

"""

returns list of all possible paths from start node to the end node

"""

path = path + [thisNode]

if thisNode == end:

return path

for nextNode in graph.childrenOf(thisNode):

if nextNode not in path:

newPath = buildPaths(graph, nextNode, end, path, totalPaths)

if newPath != None:

if totalPaths == None:

totalPaths = [newPath]

else:

totalPaths.append(newPath)

return totalPaths

为空路径显式返回None。在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值