zoukankan      html  css  js  c++  java
  • 匿名函数、异常处理

    day14 匿名函数

    lambda 参数:返回值

    max(args,key=func)

    key=func做的事情

    1. 循环遍历参数
    2. 然后把所有的key值依次丢入func中返回薪资
    3. 通过返回的薪资排序,得到最大值

    filter(func,[1,2,4,5])

    帅选为功能函数中的内容为真的内容

    map(func,[1,2,3,4,5])

    功能函数中的内容加函数功能

    内置函数

    bytes()

    chr(对应排序) / ord(对应符号) 艾塞克码

    divmod() 返回元组,取整/取余

    enumerate() 把值和索引取出来

    eval() 把字符串的引号去掉,留下来的是什么就是什么

    hash() 可变不可哈希

    abs()

    all()可迭代对象内的元素全部为Ture则为True

    any() 可迭代对象内的元素有一个为True则为True

    dir()列出所有模块的方法

    gloabals 列出所有全局变量

    locals

    异常处理

    try : 
        代码块
    except  报错名称:
        代码块
    

    assert 断言+ 条件

    raise 主动抛出错误

  • 相关阅读:
    如何写Makefile?
    C语言变量的存储类别详解
    Longest Palindrome Substring
    Count Primes
    Closest Binary Search
    Search Insert Position
    Set Matrix Zeros ****
    Search for a Range
    Two Sum II
    Jump Game
  • 原文地址:https://www.cnblogs.com/kaizi111/p/11624862.html
Copyright © 2011-2022 走看看