In this tutorial, we are going to learn about how to get the current year in Python.
To get the current year in Python, first we need to import the
date class from the
datetime module and call a
today().year property on it.
year property returns the current year in four-digit(2023) string format according to the user’s local time.
Here is an example:
from datetime import date current_year = date.today().year print(current_year)