如果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()

结果:

 

posted on 2018-04-07 10:21  当太阳不再发光  阅读(8425)  评论(0编辑  收藏  举报