从最后一个往回走一步是谁
运行下面这段程序:
class DNode:
def __init__(self, name):
self.name = name
self.next = None
self.prev = None
def dbuild(names):
head = None
tail = None
for x in names:
nd = DNode(x)
if head is None:
head = nd
else:
tail.next = nd
nd.prev = tail
tail = nd
return head, tail
head, tail = dbuild(["阿岚", "小满", "阿泰", "南风"])
print(tail.prev.name)
全部评论