Python3 函数return
1 # def logger(): 2 # f = open("loge.txt","a") 3 # f.write("2017-09-15 exec function") 4 # f.close() 5 # print("2017-09-15 exec function") 6 # 7 # print("--------------------") 8 # 9 # # 返回值 10 # def f(): 11 # print('OK') 12 # 13 # return 11 # 返回什么内容给谁 14 # print(123) # 不会执行 15 # a = f() 16 ''' 17 默认返回None,返回一个对象 18 将返回的值赋给a 19 作用:1.结束函数,2.返回某个对象 20 ''' 21 22 # def add(*args): 23 # print(args) 24 # Sum = 0 25 # for i in args: 26 # Sum += i 27 # print(Sum) 28 # return Sum 29 # 30 # a = add(1,2) 31 # print(a) 32 # 33 # def foo(): 34 # return 3,'123',[3,2] 35 # 36 # b = foo() 37 # print(b) 38 39 ''' 40 1.函数如果没有return,默认返回None 41 2.如果return多个对象,那么Python会帮我们把这多个对象封装成一个元组,其实返回的也是一个对象 42 '''