列表(数组):
数组需要一块连续的内存空间来存储,对内存的要求比较高。
补充:1个整型占4个字节,1个字节占8位,即1个整型占32位
举例:
单链表的实现:
# class Hero(object):
# def __init__ (self,no=None,name=None,nickname=None,pNext=None):
# self.on = no
# self.name = name
# self.nickname = nickname
# self.pNext = pNext
# class Hero(object):
# def __init__ (self,no=None,name=None,nickname=None,pNext=None):
# self.on = no
# self.name = name
# self.nickname = nickname
# self.pNext = pNext
# 这种方式只能在后面添加
# def add(head,hero):
# head.pNext = hero
# def showAll(head):
# while head.pNext!=None:
# head =head.pNext
# print(head.name)
# def add(head,hero):
# head.pNext = hero
# def showAll(head):
# while head.pNext!=None:
# head =head.pNext
# print(head.name)
-
-
在生产者端,设置
properties = pika.BasicProperties(
delivery_mode=2, # make message persistent
) -
在消费者端
auto_ack = False
ch.basic_ack(delivery_tag=method.delivery_tag)