import 文件的地址
https://blog.csdn.net/qq_21944445/article/details/99705171
# coding:utf-8
from linklist import LinkList
# 栈
class Stack(LinkList):
def __init__(self):
super().__init__()
def is_empty(self):
# 判空
return super().is_empty()
def append(self, item):
# 尾部添加
super().append(item=item)
def pop(self):
# 尾部删除
if self._head is not None:
cur = self._head
if cur.next is None:
self._head = None
else:
while cur.next.next is not None:
cur = cur.next
cur.next = None
def return_item(self):
# 返回尾部元素
cur = self._head
while cur is not None:
if cur.next is None:
return cur.item
else:
cur = cur.next
return 'No item'
def length(self):
return super().lengt