“Python czekaj” Kod odpowiedzi

Python czekaj 1 s.

import time
 
# Wait for 5 seconds
time.sleep(5)
 
# Wait for 300 milliseconds
# .3 can also be used
time.sleep(.300)
Blushing Bat

Opóźnienie czasowe Pythona

import time
while True:
    print("This prints once a minute.")
    time.sleep(60) # Delay for 1 minute (60 seconds).
Dangerous Dugong

Funkcja oczekiwania Python

import time
#Waits 1 second
time.sleep(1)
DatMADCoder

Python poczekaj aż

import time
def waitUntil(condition, output): #defines function
    wU = True
    while wU == True:
        if condition: #checks the condition
            output
            wU = False
        time.sleep(60) #waits 60s for preformance

waitUntil(Cookies >= 0, eatCookies()) #runs function (output MUST be another function)
Whoop de Doop

kod Pythona do poczekać

# You need to import time first
import time
#now you have time you can make time wait/sleep
time.sleep(10)
#time will wait/sleep for 10 seconds
Testy Tapir

Python czekaj

import time

def wait_until(somepredicate, timeout, period=0.25, *args, **kwargs):
  mustend = time.time() + timeout
  while time.time() < mustend:
    if somepredicate(*args, **kwargs): return True
    time.sleep(period)
  return False
Bewildered Beaver

Odpowiedzi podobne do “Python czekaj”

Pytania podobne do “Python czekaj”

Więcej pokrewnych odpowiedzi na “Python czekaj” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu