创建
class Node: def __init__(self, item): self.item = item self.next = None def create_link_list(lis): head = Node(lis[0]) for element in lis[1:]: node = Node(element) node.next = head head = node return head if __name__ == '__main__': lis1 = [1, 2, 3] node_obj = create_link_list(lis1) print(node_obj.item) print(node_obj.next.item) print(node_obj.next.next.item)