import math
import datetime
import msvcrt
timer0_timup_bol = bool(0)
timer0_interval_in=2000
timer0_interval = 1000
timer0_interval_hafe=1000
if timer0_interval_in>1000:
timer0_interval = timer0_interval_in
timer0_interval_hafe = int(math.floor(timer0_interval / 2))
bol_stato_tim = bool(0)
bol_hafe_time0 = bool(0)
count=0
my_over_bol = bool(0)
bol_set_time0 =bool(0)
my_count_tim =0
my_count_tim_sub = 0
while True:
now = datetime.datetime.now()
formatted_now = now.strftime("%Y-%m-%d %H:%M:%S.%f")
# print(formatted_now)
#2024-01-12 15:32:11.123456
new_tim0_now = 0
arrey_time_now = formatted_now.split(":")
time0_now_sec=int(float(arrey_time_now[2])*1000)
if new_tim0_now != time0_now_sec:
new_tim0_now = time0_now_sec
my_count_tim_sub += 1
if my_count_tim_sub > 60:
my_count_tim += 1
# print (my_count_tim_sub,";",my_count_tim,"\n")
my_count_tim_sub = 0
if my_count_tim == timer0_interval_hafe and bol_set_time0 == (0):
display = "□"
print (display,my_count_tim,":",timer0_interval_hafe,"\n")
bol_set_time0 =bool(1)
bol_hafe_time0 = bool(1)
#elif my_sectr_tim % timer0_interval <= timer0_interval_hafe and bol_set_time0 == (1):
elif my_count_tim == timer0_interval and bol_set_time0 == (1):
bol_set_time0 = bool(0)
display = "■"
print (display,my_count_tim,":",timer0_interval_hafe,"\n")
# bol_hafe_time0 = bool(0) #time up after cller
if my_count_tim == timer0_interval and bol_hafe_time0 ==(1):
bol_set_time0 = bool(0)
timer0_timup_bol = bool(1)
my_count_tim = 0
bol_hafe_time0 = bool(0)
#it cller
#s = msvcrt.getch().decode('utf-8')
if count >=10 and timer0_timup_bol ==(1):
print ("Geme Over\n")
my_over_bol = bool(1)
elif timer0_timup_bol ==(1):
count +=1
timer0_timup_bol = bool(0)
print (int(count), "\n")
if my_over_bol==(1):
break
elif msvcrt.kbhit():
x = msvcrt.getch().decode('utf-8')
print(f"Received input: {x}")
break
exit()
1/100と1/60間違えていませんか?
さらに10分の10倍にして10secをストップウォッチで、計ってみてください。