Wednesday, 11 May 2016

How to find last day of current month and first day of current month in Python ?

For finding last day of current month, we need to use calendar and datetime python libraries.

Following is an example of it.

>>> import calendar
>>> import datetime

>>> calendar.mdays[datetime.date.today().month]
31

>>> datetime.datetime.today().replace(day=1)
It will replace today's date with starting date of month.

I hope you like this article. Share your views to improve content. Happy Learning !!!

How to install python3.12 in Linux?

First we have to add repository source code so open terminal and run following command: sudo add-apt-repository ppa:deadsnakes/ppa     Next...