一、面向对象实现栈的数据结构
#!/usr/bin/env python
#coding:utf-8
"""
file:StackV2.py
date:9/9/177:57 PM
author:hx
desc:通过面向对象的方式实现栈的数据结构
"""
class stack(object):
def __init__(self):
self.stack = []
def PushStack(self,item):
self.stack.append(item)
def PopStack(self):
if self.stack == []:
print "No element to pop"
else:
self.stack.pop()
print "Pop successfully"