Python栈类实例分析
时间:2021-03-29 09:41:04|栏目:Python代码|点击: 次
本文实例讲述了python栈类。分享给大家供大家参考。具体如下:
class Path: #a list used like a stack
def __init__(self):
self.P = []
def push(self,t):
self.P.append(t)
def pop(self):
return self.P.pop()
def top(self):
return self.P[-1]
def remove(self):
self.P.pop(0)
def isEmpty(self):
return (len(self.P)==0)
def printPath(self):
print self.P
希望本文所述对大家的Python程序设计有所帮助。
上一篇:Pytorch 使用opnecv读入图像由HWC转为BCHW格式方式
栏 目:Python代码
下一篇:Python2和Python3中print的用法示例总结
本文标题:Python栈类实例分析
本文地址:http://www.codeinn.net/misctech/90131.html






