无意中发现python中可以有同名函数存在不会报错。
代码如下:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @ Time :2020/9/7 22:56
# @ Author :BT烤翅
"""题目:练习函数调用。"""
def hello():
print('frist_hello world')
hello()
def hello(
本文探讨了Python中允许同名函数存在的现象,通过示例代码展示了调用时如何选择最近定义的函数。当函数定义缺失时,会抛出NameError。读者将了解到Python函数查找和调用的规则。
无意中发现python中可以有同名函数存在不会报错。
代码如下:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @ Time :2020/9/7 22:56
# @ Author :BT烤翅
"""题目:练习函数调用。"""
def hello():
print('frist_hello world')
hello()
def hello(

被折叠的 条评论
为什么被折叠?