简易的首考/高考倒计时
rt. 适用于浙江考生。from time import time, sleep
from os import system
first = 1609891200 # 2020/1/6 8:00
second = 1623024000 # 2021/6/7 8:00
now = int(time())
width = 22
if now < first: target = first; tip = '首考倒计时'.center(width-5)
elif now < second: target = second; tip = '高考倒计时'.center(width-5)
else: print('Good luck!'); tip = ''
system(f'mode con: cols={width} lines=2')
sleep(0.1)
print(tip)
t = target - now
def f(x):
return str(x) if x >= 10 else f'0{x}'
while t >= 0:
t = target - int(time())
d = t // 86400
t = t % 86400
h = f(t // 3600)
m = f(t // 60 % 60)
s = f(t % 60)
print(f'{d}天{h}时{m}分{s}秒'.center(width-4), end='\r')
sleep(1)
input()
运行界面如下:
如果前面XX倒计时的字被很多行时间覆盖,使用下面的代码:
from time import time, sleep
from os import system
first = 1609891200 # 2020/1/6 8:00
second = 1623024000 # 2021/6/7 8:00
now = int(time())
width = 22
if now < first: target = first; tip = '首考倒计时'.center(width-5)
elif now < second: target = second; tip = '高考倒计时'.center(width-5)
else: print('Good luck!'); tip = ''
system(f'mode con: cols={width} lines=3')
sleep(0.1)
print(tip)
t = target - now
def f(x):
return str(x) if x >= 10 else f'0{x}'
while t >= 0:
t = target - int(time())
d = t // 86400
t = t % 86400
h = f(t // 3600)
m = f(t // 60 % 60)
s = f(t % 60)
print(f'{tip}\n'+f'{d}天{h}时{m}分{s}秒'.center(width-4))
sleep(1)
system('cls')
input()
linux下把倒数第二行的system('cls')改为system('clear')即可使用。 感觉可以改进一下,
比如隐藏任务栏,
再比如窗口置顶显示,
再比如调用winapi显示在桌面上(防止窗口遮挡或拖拽的问题)。
学习研究嘛,起因都是折腾{:301_1001:} 随着技术的提升,论坛中的CB会越来越多,
也就越来越会发现自己是个菜逼。哈哈哈哈哈哈哈哈哈哈 这个软件确实不错的啊 我终于有帐号啦!!!感谢分享!!! 感谢 分享 很不错 谢谢谢谢分享 感谢楼主分享 不错,感谢分享{:1_893:} 虽然用不上,好评了 小计时器,很好玩哈哈 很不错的软件分享,谢谢楼主。