Форум сайта python.su
Здравствуйте! Хочу написать для своей игры улучшение, которое будет действовать в течении 30 секунд. Для этого воспользовался модулем time и создал цикл while.
import time # timeout variable can be omitted, if you use specific value in the while condition timeout = 300 # [seconds] timeout_start = time.time() while time.time() < timeout_start + timeout: test = 0 if test == 5: break test -= 1 #Пример print('example')
import time # timeout variable can be omitted, if you use specific value in the while condition timeout = 300 # [seconds] timeout_start = time.time() while time.time() < timeout_start + timeout: test = 0 if test == 5: break test -= 1 #Пример print('example')
Офлайн
http://python.su/forum/topic/30947/?page=1#post-168204
Офлайн