2014-11-08 122 views

回答

0

一個想法是使用時間和while循環如下:

import time 

TIMES = 10 


def main(): 
    pass 
    # your code here 


if __name__ == '__main__': 
    time_start = time.time() 

    # run main() function TIMES times in 1 sec. 
    i = 0 
    while True: 
     time_current = time.time() 
     if time_current > time_start + i/float(TIMES): 
      print('{}: {}'.format(i, time_current)) 
      main() 
      i += 1 
     if i > 9: 
      break 

僅供參考。

相關問題