python计算,指定的日期,后n天,前n天是哪一天

xiaoxiao2021-02-28  108

#!/usr/bin/python #coding=UTF-8 import datetime def getday(y=2017,m=8,d=15,n=0): the_date = datetime.datetime(y,m,d) result_date = the_date + datetime.timedelta(days=n) d = result_date.strftime('%Y-%m-%d') return d print getday(2017,8,15,21) #8月15日后21天 print getday(2017,9,1,-10) #9月1日前10天
转载请注明原文地址: https://www.6miu.com/read-74214.html

最新回复(0)