zoukankan      html  css  js  c++  java
  • 列表内有字符串后反转加排序(python 2.7实现)

    反转加排序:
    a=["123","456","231"]
    第一种办法
    sorted(map(lambda x:"".join([i for i in (lambda x:reversed(list(x)))(x)]),a))
    第二种办法
    sorted(map(lambda x:x[::-1],a))
     
    处理之后:
    #encoding=utf-8
    import traceback
    def listrs1(lista):
        if isinstance(a,list):
            try:
                print sorted(map(lambda x:"".join([i for i in (lambda x:reversed(list(x)))(x)]),a))
            except Exception,e:
                print u"执行反转排序出现的问题是{0}".format(traceback.print_exc())
        else:
            print u"传入内容有误"
     
    def listrs2(lista):
        if isinstance(a,list):
            try:
                sorted(map(lambda x:x[::-1],a))
            except Exception,e:
                print u"执行反转排序出现的问题是{0}".format(traceback.print_exc())
        else:
            print u"传入内容有误"
    if __name__=="_main__":
        a=["123","456","231"]
        listrs1(a)
        listrs2(a)
  • 相关阅读:
    Number Clicker CodeForces
    We Need More Bosses CodeForces
    Tree Constructing CodeForces
    Berland and the Shortest Paths CodeForces
    Allowed Letters CodeForces
    Military Problem CodeForces
    FFT自看
    Communication System
    Dollars
    Coin Change
  • 原文地址:https://www.cnblogs.com/zhangtebie/p/11185836.html
Copyright © 2011-2022 走看看