0 votes
1 view
in Python by (1.6k points)
Is there a way using Python's standard library to easily determine (i.e. one function call) the last day of a given month?

If the standard library doesn't support that, does the dateutil package support this?

1 Answer

0 votes
by (25.1k points)

You can simply use the monthrange methods from python's calendar. This method will return a tuple with first element as start of the month and second element as the end of the month. So to get the last day of the month.

module.calendar.monthrange(year, month)[1]

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...