下面的代码中使用了python队列

下面的代码中使用了python队列,python,queue,stack,Python,Queue,Stack,有人能给我解释一下这个密码吗??当您创建一个对象时,它实际上是做什么的…,例如: class stack(): def __init__(self): self.items=[] def push (self,item): self.items.append(item) def pop (self): return self.items.pop() def length(self):

有人能给我解释一下这个密码吗??当您创建一个对象时,它实际上是做什么的…

,例如:

class stack():
     def __init__(self):
          self.items=[]
     def push (self,item):
          self.items.append(item)
     def pop (self):
          return self.items.pop()
     def length(self):
          return (len(self.items))
您可以访问该类中的定义,如:

obj=stack()

你的意思是要解释的不仅仅是代码定义了一个完全无用的类,而且代码样式非常难看(不仅仅是语法上的)?在这里学习:
obj.push(3)
"""adds number 3 to your stack"""

obj.pop()
"""returns last item from your stack that was inserted into it and deletes it from the stack (in this case 3)"""

obj.length()
"""returns length of your stack, now it is 0 but if we didn't perform obj.pop() that would be 1"""