代码
import time
import sys
leave=0
print ("==========虚拟跑步机=========")
print (30 *"#")
weight=float(input("输入您的体重(kg):"))
speed=float(input("速度(千米/小时):"))
times=int(input("跑步时间(分钟):"))
times=times*60
while leave<times :
leave+=1
min, sec = divmod(times-leave,60)
leave_time=str(min)+'分'+str(sec)+'秒'
dista=leave/3600 * speed
calor =weight * 30/(400/(speed*1000/60)) * leave/60/60
sys.stdout.write('\r')
sys.stdout.write('剩余时间:{} 跑步距离:{:.2f}千米 消耗热量:{:.2f} 千卡'.format(leave_time,dista,calor))
sys.stdout.flush
time.sleep(1)
效果