>>> abs(-9)
9
>>> l = (2,1,3,5,77,222,97)
>>> max
<built-in function max>
>>> max(l)
222
>>> min(l)
1
>>> a = "hello"
>>> len(a)
5
>>> divmod(5,2)
(2, 1)
>>> divmod(2,5)
(0, 2)
divmod ,返回商和余数的一个元组。
pow(x,y),返回x的y次方
pow(x,y,z),返回x的y次方,再对y取余
>>> round(1.1)
1.0
>>> round(1.6)
2.0
>>> round(1.5)
2.0
>>> round(1.4)
1.0
>>> callable(min)
True
>>> callable(ff)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name ‘ff‘ is not defined
>>> f = 100
>>> callable(f)
False
>>> l = [1,2]
>>> type(l)
<type ‘list‘>
>>> type([])
<type ‘list‘>
>>> if type(l) == type([]):
... print "True"
...
True
>>> isinstance(l,list)
True
>>> isinstance(l,int)
False
>>> cmp(1,1)
0
>>> cmp(1,4)
-1
>>> cmp(8,4)
1
>>> cmp("1","2")
-1
>>> cmp("1","0")
1
>>> cmp("1","1")
0
>>> range(10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> xrange(10)
xrange(10)
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/chenguibao/article/details/48104987