python内置函数目前需要知道的如下:
代码:
#!/usr/bin/env python# -*- coding:utf-8 -*-# author by lh #map(函数,可迭代的对象)def f1(x): return x+100ret=map(f1,[1,2,3,4,5])for i in ret: print iprint ‘---------------------------------------‘#hash转换成哈希值,节约内存dic={ ‘dvfhsuicbfhascjnbj‘:‘123‘}r=hash(‘dvfhsuicbfhascjnbj‘)print rprint ‘---------------------------------------‘#isinstance判断某个对象是否是某个类创建的li=[11,22,33]r=isinstance(li,list)print rprint ‘---------------------------------------‘ #iter创建一个可迭代的对象obj=iter([11,22,33,44])r1=next(obj)print r1print ‘---------------------------------------‘#zipli1=[11,22,33,44]li2=[‘a‘,‘b‘,‘c‘,‘d‘]r=zip(li1,li2)for i in r: print i
运行结果:
时间: 2024-10-06 08:56:01