Python学习笔记六:return的用法
2015-02-01 18:29
519 查看
#coding:utf-8 def testReturn(x): if x > 10000: return print "test return!!" #这句话永远不会得到执行 elif x > 1000: return 100 elif x > 100: return 10 elif x > 10: return 1 else: return 0 print testReturn(9999999) #result = None print testReturn(9999) #return = 100 print testReturn(999) #return = 10 print testReturn(99) #return = 1 print testReturn(9) #return = 0 #return使用说明: #(1)返回函数的返回值 #(2)终止程序的运行,提前退出.(例如:当函数内有错误发生时,使用return可以终止函数的运行)
相关文章推荐
- Python学习笔记六:return的用法
- python3.4学习笔记(二十) python strip()函数 去空格\n\r\t函数的用法
- Python学习笔记(4)Python中super的用法
- GO学习笔记 - 没有参数的 return 语句返回各个返回变量的当前值,这种用法被称作“裸”返回。
- 【python学习笔记】Python中*args 和**kwargs的用法
- python学习笔记之常用模块用法分析
- Python学习笔记(补充)Split 用法
- python学习笔记--split与join用法
- Python的装饰器用法学习笔记
- Python学习:纠错笔记:详解os.removedirs(path)的正确用法
- 三、PYTHON 学习笔记之 join 和 split 函数用法
- Python学习笔记(4)Python中super的用法
- Python学习笔记:05 数组的基本用法(Tuple和List)
- python学习笔记:range()函数用法
- python 学习 笔记 format 用法
- python中*args 和 **kwargs 的用法学习笔记
- Python学习笔记——print语句用法总结
- Python学习笔记(3)range的用法
- Python学习笔记——Property用法
- Python学习笔记 --- 学会super用法