|
发表于 2019-4-30 19:59:45
From FishC Mobile
|
显示全部楼层
本帖最后由 一X一 于 2019-4-30 20:14 编辑
channel21138 发表于 2019-4-30 16:56
函数地址?
严格来说也不叫地址,而是函数的变量名,你上机实际输出一下就可以明白
我演示一下 看能否明白
- >>>def test():
- def funIn():
- print(2)
- return 5
- return funIn
- >>> t=test()
- >>> t
- <function test.<locals>.funIn at 0x00A9B660>
- >>> t()
- 2
- 5
- >>> def test():
- def funIn():
- print(2)
- return 5
- return funIn()
- >>> t1=test()
- 2
- >>> t1
- 5
- >>> t1()
- Traceback (most recent call last):
- File "<pyshell#13>", line 1, in <module>
- t1()
- TypeError: 'int' object is not callable
- >>>
复制代码 |
|