Python 实现倒计时功能,可用于购物界面的活动倒计时

'''
Author:Amos
功能:实现倒计时功能,可用于购物界面的活动倒计时
'''
import datetime
day20 = datetime.datetime.strptime('2019-02-08 0:0:0','%Y-%m-%d %H:%M:%S')
now = datetime.datetime.today()
delta = day20 - now
day = delta.days
hour = int(delta.seconds/60/60)
minutes = int((delta.seconds-hour*60*60)/60)
seconds = delta.seconds-hour*60*60-minutes*60
print('\033[30;43m距离结束:\033[0m'+ 
'\033[1;31;43m'+str(day)+'\033[0m'+'\033[30;43m天\033[0m'+
'\033[1;31;43m'+str(hour)+'\033[0m'+'\033[30;43m时\033[0m'+
'\033[1;31;43m'+str(minutes)+'\033[0m'+'\033[30;43m分\033[0m'+
'\033[1;31;43m'+str(seconds)+'\033[0m'+'\033[30;43m秒\033[0m')

你可能感兴趣的:(Python)