其他分享
首页 > 其他分享> > 计算上一周周三的日期

计算上一周周三的日期

作者:互联网

直接上code了

 

def get_wed_date():
"""
This function obtains last Wednesday date
"""

uni_string = lambda month,day: "".join([str(month), str(day)]) if len(day) > 1 else \
"".join([str(month), "0", str(day)])

logging.info("Start to calculate the last Wednesday date\n")
today = datetime.date.today()
logging.info("Today date: {0}\n".format(uni_string(str(today.month), str(today.day))))
weekday = today.weekday()
last_wed = today - datetime.timedelta(days=weekday + 5)
last_last_wed = today - datetime.timedelta(days=weekday + 12)
wed_list = [uni_string(str(last_wed.month), str(last_wed.day)), uni_string(str(last_last_wed.month), str(last_last_wed.day))]
logging.info("Last Wednesday date: {0}\n".format(wed_list[0]))
logging.info("Last Last Wednesday date: {0}\n".format(wed_list[1]))
return wed_list

程序运行打印如下:

 


  参考博客:

   https://blog.csdn.net/cxl0406/article/details/118673909

 

标签:last,wed,一周,日期,周三,str,date,day,today
来源: https://www.cnblogs.com/boyangchen/p/15338513.html