Как вызывать функцию каждые 2 секунды в Python? [закрыто]

С версией JavaScript 1.6 это так же просто:

Array.prototype.equals = function( array ) {
  return this.length == array.length && 
         this.every( function(this_i,i) { return this_i == array[i] } )  
  }

Например, [].equals([]) дает true, а [1,2,3].equals( [1,3,2] ) дает false.

-2
задан Orr Burgel 2 March 2019 в 22:05
поделиться

1 ответ

Модуль sched может сделать это:

import sched, time
schedTimer = sched.scheduler(time.time, time.sleep)
def increaseX(x):
    x += 1
    print('X increased to ' + str(x))
    schedTimer.enter(2, 1, increaseX, (x,))
schedTimer.enter(2, 1, increaseX, (3,))
schedTimer.run()
0
ответ дан GKE 2 March 2019 в 22:05
поделиться
Другие вопросы по тегам:

Похожие вопросы: