1 1,print 的格式化输出
2
3 def fun (x,y):
4 print ("niihao %s : %s" % (x,y)) ###此处x y 必须使用()
5 fun(88,99)
6
7 ----
8 def fun (x,y):
9 print (x,"nihao",y) ###当然也可以这样进行输出
10 fun(88,99)
11
12 1,帮助函数
13 help(内置函数名)
14 help(对象.方法名)
15
16
17 2,数据相关函数
18
19 abs() --求绝对值(参数必须为数字类型)
20 max()
21 min()
22 divmod()
23 --求商和余
24 divmod(5,2) 结果为 (2,1)
25
26 round()
27 ---返回浮点数(参数必须为整数)
28
29 2,其它函数
30 callable()
31 --判断某一函数是否可被调用
32 --可被调用,返回TURE 否则返回FALSE(如果为变量) 如果即不是变量也不是函数,则直接报错,未定义
33
34
35 3,类型转换函数
36 tuple()
37 ---将列表转换成元组
38 a=(1,2,4)
39 tuple(a)
40
41 list()--将元组转换成列表
42 int()---将字符转换成数字
43 str()
44 list()
45 tuple()
46 hex()
47 type()
48 isinstance()
49
50 type(变量名或函数名)
51 --查看对象的类型
52 if type(list)==type([]):
53 print "此为列表"
54
55 type(list)=="list" 此种写法错
56
57
58 isinstance()
59 --判断对象的类型(类型不用加引号)
60 isinstance(l,list)
61 isinstance(x,int)