待解决
已受理
待回复
完成
Question title : QuecPython是否支持队列
Work order Number : FIE585287549910
Work order type : 需求
Submission time : 2021-02-09 11:41:57
Work order status : 完成
Contact information : Email
Contact information : dav******g@quectel.com

Communication record

  • 问题描述:
    QuecPython是否支持队列
  • david.tang : 已收到您的工单,我们将会尽快安排人手进行处理。
    2021-02-09 11:42:08
  • david.tang :

    队列是一种先进先出的数据结构,主要操作包括入队,出队。入队的元素加入到对尾,从队头取出出队的元素。在QuecPython中我们可以使用list操作来模拟队列:

    class queue:
    def __init__(self):
    self.__alist = []

    def push(self, value):
    self.__alist.insert(0, value)

    def pop(self):
    return self.__alist.pop()

    def size(self):
    return len(self.__alist)

    def clean(self):
    self.__alist.clear()

    def isEmpty(self):
    return self.__alist == []

    def showQueue(self):
    print(self.__alist)

    运行:

    if __name__ == '__main__':
    q = queue()
    q.push(
    1)
    q.push(
    "123")
    q.push(
    "456")
    q.push(
    2)
    q.showQueue()
    print(q.pop())
    print(q.pop())
    print(q.pop())
    print(q.pop())
    q.showQueue()


    2021-02-09 11:42:30
  • david.tang : 客服已经将本工单结束,如有疑问请重新发起工单咨询,谢谢!
    2021-02-09 11:42:38

Waiting for your appraise