Python:列表打印__main __。节点对象位于0x102377f98

时间:2016-05-01 14:18:18

标签: python

我的字符串列表的输出是一个节点对象,而不是像[1,2,3]那样的正常输出,我该如何解决这个问题?

class Node:

    def __init__(self, item, link):
        self.item = item
        self.next = link

    def __str__(self):

        string = []
        item = self.top
        while item is not None:
            string.append(str(item))
            item = item.next
        return str(string)

0 个答案:

没有答案
相关问题