Python学习笔记六:return的用法
2010-03-10 08:13
393 查看
#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的用法
- python学习笔记-list的用法
- Python学习笔记:python中enumerate函数的用法
- Python的装饰器用法学习笔记
- Python学习:纠错笔记:详解os.removedirs(path)的正确用法
- Python学习笔记:05 数组的基本用法(Tuple和List)
- 【python学习笔记】Python中*args 和**kwargs的用法
- python学习笔记(一)一些基础用法
- Python学习笔记——部分常用/特殊用法
- Python学习笔记——Property用法
- python学习笔记-(14)python循环中的高级用法
- python学习笔记之open函数的用法
- Python学习笔记(5):lambda,filter,map,reduce,zip用法整理
- Python学习笔记 - 字典的用法
- Python学习笔记 --- 学会super用法
- python中*args 和 **kwargs 的用法学习笔记
- Python学习笔记(3)range的用法
- Python学习笔记——print语句用法总结
- Python 学习笔记(3)-Python 常用字符串函数的用法
- Python学习笔记(二)if语句的简单用法