python获取下周周一日期(获取指定周指定周几)

import calendar
import datetime


def getNextMonday():

    today = datetime.date.today()

    print today

    oneday = datetime.timedelta(days = 1)

    m1 = calendar.MONDAY

    while today.weekday() != m1:
        today += oneday

    nextMonday = today.strftime('%Y%m%d')

    return nextMonday

print getNextMonday()


=======================================================
输出:
2017-11-28
20171204

你可能感兴趣的:(python)