• 序列类型函数


    len()#返回元素个数,

    max()#最大字符(字典序)

    min()#最小字符(字典序)

    sum()#求和

    reversed():#字典序排列

    list():浅拷贝创建新列表

    tuple():浅拷贝创建新元组

    >>> s1=['name',"they're",'age','The','Ta']
    >>> for t in reversed(s1):
        print t

    Ta
    The
    age
    they're
    name

    >>> sorted(s1)
    ['Ta', 'The', 'age', 'name', "they're"]

    enumerate()#序列号

    >>> s=['age','number','name']
    >>> for i,s in enumerate(s):
        print i,s

    0 age
    1 number
    2 name

    zip()#组合

    >>> help(zip)
    Help on built-in function zip in module __builtin__:

    zip(...)
    zip(seq1 [, seq2 [...]]) -> [(seq1[0], seq2[0] ...), (...)]

    Return a list of tuples, where each tuple contains the i-th element
    from each of the argument sequences. The returned list is truncated
    in length to the length of the shortest argument sequence.

    >>> s=['name','age','number']
    >>> s1=['Tim','555','123']
    >>> for i,j in zip(s,s1):
        print ('%s %s'%(i,j))

    Name Tim
    Age 555
    Number 123

  • 相关阅读:
    PPT1 例1
    皇宫看守 树形DP
    没有上司的晚会 树形DP
    将功补过 树形DP
    战略游戏 树形DP
    选课 树形DP
    二叉苹果树 树形DP
    GDOI2016总结
    加分二叉树 树形DP
    [注意]未做的题(最短路)
  • 原文地址:https://www.cnblogs.com/timp/p/3677108.html
Copyright © 2020-2023  润新知