常见内置函数
1.abs() 绝对值
# print(abs(123))
# print(abs(-123))
# 2.all() any()
# l = [11,22,33,0]
# print(all(l)) # 所有的元素都为True结果才是True
# print(any(l)) # 所有的元素只要有一个为True结果就为True
# 3.bin() oct() hex() 进制数
# print(bin(123))
# print(oct(123))
# print(hex(123))
# 4.bytes() str()
# res = '金牌班 最牛逼'
# res1 = bytes(res,'utf8')
# print(res1)
# res2 = str(res1,'utf8')
# print(res2)
# res1 = res.encode('utf8')
# print(res1)
# res2 = res1.decode('utf8')
# print(res2)
# 5.callable() 是否可调用(能不能加括号运行)
# s1 = 'jason'
# def index():
# pass
# print(callable(s1),callable(index)) # False True
# 6.chr() ord()
# print(chr(65)) # 根据ASCII码转数字找字符
# print(ord('A')) # 65
# 7.complex() 复数
# print(complex(123)) # (123+0j)
# 8.dir() 查看当前对象可以调用的名字
# def index():
# pass
# print(dir(index))
# print(index.__name__)
# 9.divmod()
# print(divmod(101,10))
"""总数据100 每页10条 10页"""
"""总数据99 每页10条 10页"""
"""总数据101 每页10条 11页"""
# num,more = divmod(233,10)
# if more:
# num += 1
# print('总共需要%s页'%num)
# 10.eval()只能识别简单的语法 exec()可以识别复杂语法 都是将字符串中的数据内容加载并执行
# res = """
# 你好啊
# for i in range(10):
# print(i)
# """
# res = """
# print('hello world')
# """
# eval(res)
# exec(res)
# 11.isinstance() 判断是否属于某个数据类型
# print(isinstance(123,float)) # False
# print(isinstance(123,int)) # True
# 12.pow()
# print(pow(4,3))
# 13.round()
# print(round(4.8))
# print(round(4.6))
# print(round(8.5))
# 14.sum()
# l = [11,22,333,44,55,66]
# print(sum(l))15.map # 映射
16.zip # 拉链
17.filter # 过滤
18.max、min # 最大值、最小值
19.reduce # 归总
"""字符串也是可以比较大小的 内部按照ASCII码转对应的十进制数比较"""
A-Z 65-90
a-z 97-122

浙公网安备 33010602011771号