diff --git a/codes/python/chapter_stack_and_queue/linkedlist_queue.py b/codes/python/chapter_stack_and_queue/linkedlist_queue.py index 2ab7196d3..982033a54 100644 --- a/codes/python/chapter_stack_and_queue/linkedlist_queue.py +++ b/codes/python/chapter_stack_and_queue/linkedlist_queue.py @@ -30,7 +30,7 @@ class LinkedListQueue: # 尾结点后添加 num node = ListNode(num) # 如果队列为空,则令头、尾结点都指向该结点 - if self.__front == 0: + if self.__front is None: self.__front = node self.__rear = node # 如果队列不为空,则将该结点添加到尾结点后 diff --git a/docs/chapter_stack_and_queue/queue.md b/docs/chapter_stack_and_queue/queue.md index c7bf098c5..530d16a48 100644 --- a/docs/chapter_stack_and_queue/queue.md +++ b/docs/chapter_stack_and_queue/queue.md @@ -412,7 +412,7 @@ comments: true # 尾结点后添加 num node = ListNode(num) # 如果队列为空,则令头、尾结点都指向该结点 - if self.__front == 0: + if self.__front is None: self.__front = node self.__rear = node # 如果队列不为空,则将该结点添加到尾结点后