python 内置函数二

Posted luoliang-gaoyu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 内置函数二相关的知识,希望对你有一定的参考价值。

s="6*8"
a=eval(s)
print(a)
#filter与map
a=[10,20,30,40]
new_list=map(lambda x:x+10,a)
b=list(new_list)
print(b)
def x(b):
c=b+10
return c
c=map(x,a)
d=list(c)
print(d)
def bb(x):
if(x>=30):
return True
else:
return False
c=filter(bb,a)
print(list(c))
#frozenset 冻结set集合 表示这个set集合只能查询不能修改
print(globals()) # 得到所有的全局变量
print(locals())#得到所有的局部变量
#hash 主要用于字典中的key,
#hex(10)得到对应的16进制
#id()得到这个对象的地址
a=[1,2,3,4]
for b in iter(a):
print(b)
b=max(1,3,2,10,32)
# print(b)
a=oct(8) #得到8进制
print(a)
b=pow(2,3)
print(b)
a=[1,2,3,45,51]
for i in range(0,5):
print(a[i])
print(range(0,5)) #python2是直接输出0,1,2,3,4,。python3 进行了优化。只有在需要数据的时候再返回值
#repr 会调用本身的__repr__()方法
c=[1,2,3,4,5]
d=reversed(c)
print(list(d))
b=round(4.6)
print(b)
b=sum([3,4,5,6])
print(b)
#super 比如有个父类有个方法A()
#你想调用A父类的A方法,你就可以使用super().A()
print(vars())
a=[1,2,3]
b=[4,5,6]
c=[7,8,9]
d=zip(a,b,c)
print(list(d))























































以上是关于python 内置函数二的主要内容,如果未能解决你的问题,请参考以下文章

python内置函数三

python 内置函数 装饰器

python 内置函数 compile()

PYDay6- 内置函数验证码文件操作

Python chr / ord 函数区别和使用

python内置函数(上篇)