#栈的实现,入栈判断是否Full,出栈判断是否Empty
class Stack():
def __init__(st,size):
st.stack=[];
st.size=size;
=-1;
def push(st,content):
if st.Full():
print "Stack is Full!"
else:
st.stack.append(content)
=+1
def Out(st):
if st.Empty():
print "Stack is Empty!"
else:
=-1
def Full(st):
if ==st.size:
return Ture
else:
return False
def Empty(st):
if ==-1:
print "Stack is Empty!"
举例:
>>>q=stack(7) #初始化栈的容量为7,并赋给q
>>>q.Empty() #检查栈是否为空
Ture
>>>q.push("hello") #进栈,推送“hello”到栈内
>>>q.Empty() #检查栈是否为空
Flase
>>>q.out #出栈
















