#return的用法:
#return用于退出函数,选择性的返回一个表达式。
def test1(a,b):
total = a+b
return total
print(total)

def test2(a,b):
total = a+b
print(total)
return total

test1(1,2) #没有任何输出结果,因为在执行print()语句前,便退出方法了
test2(1,2) #结果为:3
posted on 2018-05-28 15:02  一只悠哉的悠哉酱  阅读(169)  评论(0编辑  收藏  举报