4
我有一个应用程序,其中,为了测试,我需要用特定时间戳替换time.time()调用,我已经在过去使用ruby做过猴子补丁time.time()python
(代码可在这里:http://github.com/zemariamm/Back-to-Future/blob/master/back_to_future.rb)
但是我不知道如何使用Python来做到这一点。
任何提示? 干杯, 泽玛丽亚
我有一个应用程序,其中,为了测试,我需要用特定时间戳替换time.time()调用,我已经在过去使用ruby做过猴子补丁time.time()python
(代码可在这里:http://github.com/zemariamm/Back-to-Future/blob/master/back_to_future.rb)
但是我不知道如何使用Python来做到这一点。
任何提示? 干杯, 泽玛丽亚
您可以简单地设置了time.time指向新的计时功能,像这样:
import time
def my_time():
return 0.0
old_time = time.time
time.time = my_time