1.当函数有多个返回值时, 其多个返回值将以元组的形式出现 def test1(): print("in the test1") return 'end' def test2(): print("in the test2") def test3(): print("in the test3") return 1, 'Hello',['Frank','Lee'],{'name':'Frank'} #返回一个元组 x = test1() y = te
面向对象--->对象------>Class 面向过程--->过程------>def 函数式编程--->函数---->def 函数的介绍: def fun1(): '''the function instruction''' x-=1 return x def fib(n): """Print a Fibconacci series up to n""" #对此函数的解释说明 a,b = 0,1 while
Python3 hasattr().getattr().setattr()函数简介 一.hasattr(object, name) 判断object对象中是否存在name属性,当然对于python的对象而言,属性包含变量和方法:有则返回True,没有则返回False:需要注意的是name参数是string类型,所以不管是要判断变量还是方法,其名称都以字符串形式传参:getattr和setattr也同样: class A(): name = 'python' def func(self): ret
Python函数func的信息可以通过func.func_*和func.func_code来获取 一.先看看它们的应用吧: 1.获取原函数名称: 1 >>> def yes():pass 2 3 >>> a=yes 4 >>> a.func_name 5 'yes' 6 >>> 2.获取函数的flags[后面有用,先说这个] [python docs]:The following flag bits are defined for c