lamba

python内积和点乘 python求内积_内建函数

python内积和点乘 python求内积_字符串_02

python内积和点乘 python求内积_内建函数_03

补充:

python内积和点乘 python求内积_字符串_04

如图:

python内积和点乘 python求内积_内建函数_05

举例:

python内积和点乘 python求内积_python内积和点乘_06

上例中的reduce用法:

python内积和点乘 python求内积_匿名函数_07



内建函数

python内积和点乘 python求内积_内建函数_08


如图,有137的函数、类等等

python内积和点乘 python求内积_匿名函数_09

类的单词首字母是大写的


查看函数或者类的方法:

python内积和点乘 python求内积_内建函数_10

常用的内建函数:

1.返回数字的绝对值

查看内置函数方法:

python内积和点乘 python求内积_匿名函数_11

所以:

python内积和点乘 python求内积_匿名函数_12

2.取列表最大最小值

python内积和点乘 python求内积_python_13

取大小值内建函数方法:

python内积和点乘 python求内积_python内积和点乘_14

比较多个参数:

python内积和点乘 python求内积_字符串_15

比较数字大小:

python内积和点乘 python求内积_匿名函数_16



常用内建函数

len() 函数

python内积和点乘 python求内积_python内积和点乘_17

字符串、元组、列表、字典都可以。一下为字典例子:

python内积和点乘 python求内积_内建函数_18

divmod() 内建函数:

python内积和点乘 python求内积_内建函数_19

由说明可以看出,这个函数的作用是返回两个数字的商和余数。

python内积和点乘 python求内积_内建函数_20

pow()内建函数:

python内积和点乘 python求内积_python内积和点乘_21

当两个参数的时候,等于x的y次方,当三个参数的时候,等于x的y次方再跟z取余

举例:

python内积和点乘 python求内积_内建函数_22


round() 内建函数:

python内积和点乘 python求内积_内建函数_23

举例:

python内积和点乘 python求内积_匿名函数_24


callable()内建函数:

python内积和点乘 python求内积_内建函数_25

判断这个对象是不是可调用的

举例:

python内积和点乘 python求内积_匿名函数_26

type() 内建函数:

python内积和点乘 python求内积_python_27


isinstance() 内建函数:

python内积和点乘 python求内积_内建函数_28


返回布尔值

举例:

之前定义过 l 和 s 的函数:

python内积和点乘 python求内积_字符串_29

和type的不用只处:

判断类的时候,用isinstance能更好的判断出来。


cmp() 内建函数:

python内积和点乘 python求内积_字符串_30


python内积和点乘 python求内积_内建函数_31


比较字符串:

python内积和点乘 python求内积_内建函数_32

是按照字符来比较的,不是按照长度比较的。

range() 和 xrange() 这两个之前已经见过。

类型转换,内置函数:

int()

python内积和点乘 python求内积_匿名函数_33

举例:

python内积和点乘 python求内积_python内积和点乘_34


long()

python内积和点乘 python求内积_匿名函数_35

python内积和点乘 python求内积_python_36



float()

python内积和点乘 python求内积_字符串_37


complex()

转变成一个复数

python内积和点乘 python求内积_字符串_38


str()

python内积和点乘 python求内积_内建函数_39


list()

python内积和点乘 python求内积_字符串_40

type()

python内积和点乘 python求内积_字符串_41


hex()

返回16进制的字符串

python内积和点乘 python求内积_字符串_42

python内积和点乘 python求内积_python内积和点乘_43


eval()

将16进制还原成10进制

python内积和点乘 python求内积_内建函数_44


oct() 把10进制转换成8进制

自己研究一下


chr()内建函数

    

python内积和点乘 python求内积_python内积和点乘_45

返回的是对应的ascII码的字符。

python内积和点乘 python求内积_字符串_46


ord() 内建函数

python内积和点乘 python求内积_python_47

python内积和点乘 python求内积_内建函数_48


关于字符串处理的内建函数(即,方法):

str.capitalize()

python内积和点乘 python求内积_匿名函数_49

查看方法

python内积和点乘 python求内积_python内积和点乘_50

方法说明:

python内积和点乘 python求内积_python_51

返回一个字符串,字符串的首字母被大写。

举例:

python内积和点乘 python求内积_字符串_52

str.replace()

python内积和点乘 python求内积_匿名函数_53

说明:替换字符串

python内积和点乘 python求内积_python内积和点乘_54

str.split()  

把字符串切成列表

python内积和点乘 python求内积_python内积和点乘_55

python内积和点乘 python求内积_匿名函数_56


str.join()

python内积和点乘 python求内积_python内积和点乘_57

python内积和点乘 python求内积_内建函数_58


string 模块

import sting   导入模块

很多方法

python内积和点乘 python求内积_python内积和点乘_59


打印所有小写字母

python内积和点乘 python求内积_内建函数_60

打印所有大写字母

python内积和点乘 python求内积_内建函数_61

把字符串第一个字母变成大写

python内积和点乘 python求内积_匿名函数_62

替换字符串

python内积和点乘 python求内积_内建函数_63


序列处理函数:

filter()

python内积和点乘 python求内积_内建函数_64

python内积和点乘 python求内积_python内积和点乘_65

定义函数名:

python内积和点乘 python求内积_匿名函数_66

通过函数处理后:

python内积和点乘 python求内积_python内积和点乘_67


zip()

python内积和点乘 python求内积_字符串_68

python内积和点乘 python求内积_匿名函数_69


当第三个列表的长度与前两个不同的时候,按最短的取。

python内积和点乘 python求内积_python内积和点乘_70

map()

python内积和点乘 python求内积_python内积和点乘_71


两个列表使用:

python内积和点乘 python求内积_python内积和点乘_72



reduce()

python内积和点乘 python求内积_python内积和点乘_73

python内积和点乘 python求内积_python_74



fileter   +  匿名函数

python内积和点乘 python求内积_python内积和点乘_75


map + 匿名函数

python内积和点乘 python求内积_内建函数_76


reduce + 匿名函数

python内积和点乘 python求内积_内建函数_77


列表表达式(列表重写)

举例:

python内积和点乘 python求内积_字符串_78



http://blog.51cto.com/286577399/2046935