python可视化:第一次作业,冬奥会时间倒计时

 

 

 

 

import datetime
mytoday=datetime.datetime.today()

dongaoteday=('2022-2-4')
#字符串处理成时间格式
dongaoteday = datetime.datetime.strptime(dongaoteday, "%Y-%m-%d")

d1 = datetime.datetime(dongaoteday.year,dongaoteday.month,dongaoteday.day)
d2 = datetime.datetime(mytoday.year, mytoday.month,mytoday.day)
dayCount = (d1 - d2).days
print('今天是:',d2)
print('冬运会开始时间为:',d1)
print('冬运会倒计时:',dayCount*(1),'天')

posted @ 2021-09-18 08:09  Bruce_Sun  阅读(379)  评论(0)    收藏  举报