class DLLNode(object):
def __init__(self, data, prev_link, next_link):
self.data = data
self.prev_link = prev_link
self.next_link = next_link
class DoublyLinkedList(object):
def __init__(self):
self.head=None
self.tail=None
def add_head(self, add_obj):
self.head=DLLNode(add_obj,None,self.head)
>>> x=DoublyLinkedList
>>> x.add_head(1)
Traceback (most recent call last):
File "<pyshell#20>", line 1, in <module>
x.add_head(1)
TypeError: add_head() takes exactly 2 arguments (1 given)
關於你在做什麼而不僅僅是一些代碼的一點解釋將是問你問題的更好方法。目前,讀者必須猜測這個問題。 – Rodrigue 2013-03-04 22:04:16