内置函数
什么是内置函数,就是python给你提供的,拿来直接用的函数,比如print,input等等,截止到python.3.6.2版本一共给我们提供了68个内置函数.
abs() | dict() | help() | min() | setattr() |
all() | dir() | hex() | next() | slice() |
any() | divmod() | id() | object() | sorted() |
ascii() | enumerate() | input() | oct() | staticmethod() |
bin() | eval() | int() | open() | str() |
bool() | exec() | isinstance() | ord() | sum() |
bytearray() | filter() | issubclass() | pow() | super() |
bytes() | float() | iter() | print() | tuple() |
callable() | format() | len() | property() | type() |
chr() | frozenset() | list() | range() | vars() |
classmethod() | getattr() | locals() | repr() | zip() |
compile() | globals() | map() | reversed() | __import__() |
complex() | hasattr() | max() | round() | |
delattr() | hash() | memoryview() | set() |
1.内存相关:hash,id
hash 必须是不可变的
id 查看内存地址的
2.调用相关:callable(重要)
查看一个函数是否是可调用的,可调用: =-> (),能加括号的都是可调用
def func(): pass func() print(callable(func)) #Ture 为可调用的
3.dir
扫描二维码关注公众号,回复:
4920995 查看本文章
查看此类型的数据可以执行 哪些方法
print(dir("你好"))
4.数学相关:sum,divmod,round,pow
sum:求和
print(sum([1,2,3,4])) #10
divmod:计算商和余数
print(divmod(20,3)) #(6,2)
round:整数是奇数 ->正常四舍五入 ,偶数 -> 五舍六入
pow:求次方
print(pow(2,3)) #8
5.和数据结构相关:enumerate,
enumerate:枚举