• 装饰器/内置函数


    装饰器:

            def wrapper(f):

                def inner(*args,**kwargs):

                    ret = f(*args, **kwargs)

                    return ret

                return inner

     

            @wrapper

            def func(a,b):

                print(a,b)

                return 666

            func(1,2)  # inner

        装饰器:在不改变原函数的调用(结构)下,为原函数增加额外的功能。

        装饰器的本质是闭包。

        开放封闭原则:

            对拓展开放。

            对内部修改封闭。

     

        内置函数:

            l1 = [(a,1),(b,4),(c,2)]

                min(l1,key=lambda x:x[1])

                max(l1,key=lambda x:x[1])

            zip: 拉链方法

            eval()

            exec()

            map: 生成器表达式循环模式

            filter:生成器表达式筛选模式

            reduce:可以key。

            divmod(10,3)

            type()

            abs()

            sorted() 排序  key

            sum()

            reversed()

            callable()

            all()

            any()

  • 相关阅读:
    面向对象之prototype,__proto__
    Screen对象
    location对象
    history对象
    JS计时器
    window对象
    Dom操作html详细
    终端 git log 修改样式
    null 和 NULL 判断
    textfield设置左边距
  • 原文地址:https://www.cnblogs.com/Lgongzi/p/10252221.html
Copyright © 2020-2023  润新知