Home  »  CodeSnippets   »   Get the Current Year in Python

Get the Current Year in Python

Posted: February 6, 2022 | by Site Host

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.

Share it!

See also  CSS Stop Text From Wrapping