import datetime
import time
#新建元旦時間
#將程序打包
def A():
# 設定時間
newyear =datetime.datetime(2033,10,1)
#調用當前時間
nowtime=datetime.datetime.now()
#計算時間差
#計算設定的時間減去現在的時間等於多少天
delte =newyear - nowtime
#將算出的天數除於365天,則是剩余年數
year=int(delte.days/365)
#將計算出的天數用%算出余數則是,算除n年多少天
day=int(delte.days%365)
#計算小時
hour=int(delte.seconds/60/60)
#計算分
minute=int((delte.seconds - hour*60*60)/60)
#計算秒
seconds = delte.seconds - hour*60*60 - minute*60
#輸出
print("距離 2033年10月1日\t剩余:%d年,%d天,%d時,%d分,%d秒" % (year,day, hour, minute, seconds))
#打包設置循環,循環輸出剩余時間,sleep(1):美妙循環一次
while True:
time.sleep(1)
A()