Python Library Tips: today()


Today I want to look around Today function which provided by Standard Python Library. This function can offer much of today’s date. Let’s start with printing what’s today date

from datetime import date

today variable also holding today() properties such as day,year,month,weekday etc. You can use them as follows.

Photo by Pixabay on

weekday gives you number representing week day from 0-6, Monday as first day. You can use the weekday for printing days in a week, Monday or Sunday as first day as follows

print('Today is %s ' %wdays[today.weekday()])

Published by


A developer,teacher and a blogger obsessed with Python,Dart and open source world from India

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.