Python实战之双向队列deque/queue学习笔记及简单练习

['__add__', '__bool__', '__class__', '__contains__', '__copy__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'appendleft', 'clear', 'copy', 'count', 'extend', 'extendleft', 'index', 'insert', 'maxlen', 'pop', 'popleft', 'remove', 'reverse', 'rotate']

from collections import deque
d = deque()
print(dir(d))
d.append(1)
d.append(10)
d.appendleft(1)
print(d)
# deque([1, 1, 10])
# d.clear()
# print(d)
# deque([])
b = d.copy()
# print(b)
# deque([1, 1, 10])
# d.extend(b)
# print(d)
# deque([1, 1, 10, 1, 1, 10])
# d.extendleft(b)
# print(d)
# deque([10, 1, 1, 1, 1, 10, 1, 1, 10]) print(d.count(1))
#
print(d.index(10))
#
d.insert(10,15)
# d.remove(1)
# deque([1, 10, 15])
print(d)
d.rotate(3)
# deque([1, 10, 15, 1])
print(d)
from queue import Queue
q = Queue()
q.put('')
q.put('')
print(q.qsize())
print(q.get_nowait())
print(q.get_nowait())
print(q.qsize())
#
#
#
#
上一篇:[日记&做题记录]-Noip2016提高组复赛 倒数十天


下一篇:plsql连接oracal数据库