To find the current year in Python, you can use the datetime module which contains the date class. You can create an instance of the date class using the today() method, which returns the current date. Then, you can simply retrieve the year using the year attribute.
Here's the code to find the current year:
main.py80 chars5 lines
This will output the current year in the format YYYY (e.g. 2021).
gistlibby LogSnag