1 #coding:utf-8
2
3 def testReturn(x):
4 if x > 10000:
5 return
6 print "test return!!" #这句话永远不会得到执行
7 elif x > 1000:
8 return 100
9 elif x > 100:
10 return 10
11 elif x > 10:
12 return 1
13 else:
14 return 0
15
16 print testReturn(9999999) #result = None
17 print testReturn(9999) #return = 100
18 print testReturn(999) #return = 10
19 print testReturn(99) #return = 1
20 print testReturn(9) #return = 0
21
22 #return使用说明:
23 #(1)返回函数的返回值
24 #(2)终止程序的运行,提前退出.(例如:当函数内有错误发生时,使用return可以终止函数的运行)