编程语言
首页 > 编程语言> > 【Python】计算两个日期相差多少天

【Python】计算两个日期相差多少天

作者:互联网

 

    @staticmethod
    def cha_count(start: str, end: str):
        """
        计算两个日期相差多少天
        @param start: '20210820'
        @param end: '20210827'
        @return: 7
        """
        old = datetime.datetime(int(start[0:4]), int(start[4:6]), int(start[6:8]))
        now = datetime.datetime(int(end[0:4]), int(end[4:6]), int(end[6:8]))
        count = (now - old).days
        print(count)
        return count

 

标签:count,end,start,Python,datetime,int,日期,相差,old
来源: https://www.cnblogs.com/danhuai/p/15193327.html