当前位置: 移动技术网 > IT编程>脚本编程>Python > python数组队列代码实例

python数组队列代码实例

2018年04月19日  | 移动技术网IT编程  | 我要评论

1周立波秀,刘福连简历,好听的欧美歌曲

python数组队列代码实例

class MyList:
    test = []
    def __init__(self, mylen=100):
        self.mylen=mylen
    def append(self,data):
        self.test.append(data)
        if len(self.test)>self.mylen:
            print("pop",self.test.pop(0))#取出第一个元素
            # test.remove(test[0])
        print(self.test)
    def get(self,index):
        if index<0:
            return None
        if index>len(self.test):
            return None
        return self.test[index]

mlist=MyList(4)
for i in range(2):
    mlist.append(i)

print(mlist.get(0))

print(mlist.get(3))

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网