python微妙级sleep


import time

now = time.time()

i = 0
while i < 10:
    if i > 0:
        sec = i /1000
        now = now + sec
    else:
        sec = 0

    print(i, now, sec) # sleep可以传入浮点数,也就是说可以控制到微妙也没问题,类似usleep

    time.sleep(sec)
    i = i+1
   

你可能感兴趣的:(python,import)