zoukankan      html  css  js  c++  java
  • collection模块

    from collections import namedtuple


    #用那么多tuple表示一个圆
    # Point=namedtuple("point",["x","y","z"])
    # p=Point(1,2,3)
    # p2=Point(3,2,1)
    # print(p,"x")
    # print(p,"y")
    # print(p,p2)


    #类似的用namedtuple表示一个圆
    # Cricle=namedtuple("Cricle",["x","y","r"])


    #花色和数字
    # Card=namedtuple("card",["color","number"])
    # p=Card("红色",2)
    # print(p.color)
    # print(p.number)



    #队列,先进先出
    # import queue
    # q=queue.Queue()
    # q.put(10)
    # q.put(5)
    # q.put(3)
    # print(q)
    # print(q.qsize())


    #deque双端队列
    # from collections import deque
    # q=deque([1,2])
    # q.append("a")#从后面放数据
    # q.appendleft("b")#从前面放数据
    # # deque.pop(1)#从后面去数据
    # # deque.popleft()#从前面取数据
    # q.insert(2,3)#插入数据
    # print(q.pop())
    # print(q.popleft())




    #orderdict的使用
    from collections import OrderedDict
    Op=OrderedDict([("a",1),("b",2),("c",3)])
    print(Op)
    print(Op["a"])
    for i in Op:
    print(i)
  • 相关阅读:
    Largest Submatrix of All 1’s
    Max Sum of Max-K-sub-sequence
    Sticks Problem
    Splay模版
    B. Different Rules
    链表合并 leetcode
    K个一组翻转链表
    反转链表2 leetcode
    nodejs简单仿apache页面
    HTML 5 Web Workers
  • 原文地址:https://www.cnblogs.com/648071634com/p/11703593.html
Copyright © 2011-2022 走看看