python同名函数同名参数问题


如果python有两个函数的函数名与参数列表都相同那么调用该函数时,哪个函数在后,则哪个被最终调用。

举例如下:

def test():
    print "before hello"

def test():
    print "after hello"

if __name__ == '__main__':
    test()

结果:

 

def test():
    print "after hello"
    
def test():
    print "before hello"


if __name__ == '__main__':
    test()

结果:

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM