python: 简单单链表

class Node:
    def __init__(self, data, next=None):
        self.data = data
        self.next = next

    def __str__(self):
        return str(self.data)


head = None
for i in range(1, 6):
    head = Node(i, head)
while head != None:
    print(head.next)
    head = head.next

猜你喜欢

转载自blog.csdn.net/lalalala_CG/article/details/84065426