Python Basics 0-5 (single bidirectional queue)

Source: Internet
Author: User

#多项队列
Import Collections#导入模块
D = Collections.deque ()#deque方法
D.append (' 1 ')#添加元素
D.appendleft (' 2 ')
D.append (' 1 ')
R = D.count (' 1 ')#查看队列元素出现次数
D.extend ([' Yy ',' UU ',' II '])#扩展队列也就是在后面添加元素
D.extendleft ([' A ',' B ',' C '])
Print (d)
D.rotate (1)#最后一位挪到首位 (insert data from the end of the queue into the first place)
Print (d)
Print (R)
A=d.pop ()
C=d.popleft ()
Print (a)
Print (c)


# for I in D:
# if 1 ==10:
# break
# Else:
# Print (i)

#单项队列
Import Queue #导入模块

Q=queue. Queue ()
Q.put (' 123 ') #插入数据
Q.put (' 678 ')
Print (Q.qsize ())
#q. Get () take data FIFO without writing parameters
print (Q.get ())

Python Basics 0-5 (single bidirectional queue)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.