Using DateTime:
import datetime
now = datetime.datetime.now().year
print(now)
or:
from datetime import date
year = date.today().year
print(year)
Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.