标签:函数 number index int pow getattr lte aaa nts
1,help(i)帮助
2,dir(),当前文件的所有变量及内置变量
3,vars(),当前文件的所有变量及变量的值,和内置变量及内置变量的值
4,type(i),变量的类型
5,import temp 导入模块,多次导入的效果为只导入一次。
6,reload(temp) 可以多次导入模块
7,id(i),显示变量的内存地址
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()
标签:函数 number index int pow getattr lte aaa nts
原文地址:http://www.cnblogs.com/liuye-micky/p/6938204.html