python 函数默认值的小坑啊

import datetime
import time

def test(day=datetime.datetime.now()):
    print day

while True:
    test()
    time.sleep(1)



run  result:

2015-06-05 16:52:47.106000
2015-06-05 16:52:47.106000
2015-06-05 16:52:47.106000
2015-06-05 16:52:47.106000
2015-06-05 16:52:47.106000
2015-06-05 16:52:47.106000
2015-06-05 16:52:47.106000
2015-06-05 16:52:47.106000

 

posted on 2015-06-05 16:55  雨渐渐  阅读(147)  评论(0编辑  收藏  举报

导航