Python内置函数

#print help()

print dir()

print vars()

#print type()

import temp

import temp

reload(temp)

id([12])

#is 

------------------

cmp(2,3)

cmp(2,2)

cmp(2,1)

cmp(10,1)

abs()

bool()

divmod()

max()

min()

sum()

pow(2, 11)

------------------

len()

all()

any()

------------------

chr()

ord()

hex()

oct()

bin()

------------------

print range(10)

print xrange(10)

for i in xrange(10):

    print i

for k,v in enumerate([1,2,3,4]):

    print k,v

------------------

s= 'i am {0}'

print  s.format('alex')

str(1)

------------------

def Function(arg):

    print arg

print apply(Function,('aaaa')) #执行函数

print map(lambda x:x+1,[1,2,3]) #all

print filter(lambda x: x==1,[1,23,4]) #True序列

print reduce(lambda x,y:x+y,[1,2,3]) #累加

x = [1, 2, 3]

y = [4, 5, 6]

z = [4, 5, 6]

print zip(x, y,z)

------------------

#__import__()

#hasattr()

#delattr()

#getattr()

module = __import__('temp')

print dir(module)

val = hasattr(module, 'version')

print val

------------------

#callable()

    #函数、类必须要有 __call__ 方法

#compile

#eval

com = compile('1+1','','eval')

print eval(com)

#exec语句

code = "for i in range(0, 10): print i"

cmpcode = compile(code, '', 'exec')

exec cmpcode

code = "print 1"

cmpcode = compile(code, '', 'single')

exec cmpcode

------------------

#isinstance()

#issubclass()

#super()

#staticmethod()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值