运维网's Archiver
论坛
›
Python
› python函数“转移”
darkpoon
发表于 2018-8-14 12:09:23
python函数“转移”
废话不多说,直接上代码!
def test1():
return "aaa"
def test2():
return "bbb"
test1().__code__ = test2().__code__
print test1()
bbb
通过上面的小例子,你就可以看出,函数内的返回值可以转换!
####
__code__对象的属性是只读,但是__code__属性本身不变!
页:
[1]
查看完整版本:
python函数“转移”