1、获取当前时间
import calendar,datetime today = datetime.datetime.today()
2、计算当前月份有多少天
def calc_current_month_days(): """ 计算当前月共多少天 :return: """ return calendar.monthrange(today.year, today.month)[1]
3、计算当前年份有多少天
def calc_current_year_days(): """ 计算当前年共多少天 :return: """ return 366 if calendar.isleap(int(str(today.year))) else 365
4、计算当前时间过去days天后是什么时间
def calc_current_time_add_days(days): """ 计算当前时间过去days天后是什么时间 :param days: :return: """ return (today + datetime.timedelta(days=days)).strftime("%Y-%m-%d")标签:27,return,days,datetime,2020,Python3,当前,year,today From: https://www.cnblogs.com/chushujin/p/16789212.html