Q:

get the current year in python

import datetime
now = datetime.datetime.now().year
print(now)
4
import datetime
now = datetime.datetime.now()
print(now.year, now.month, now.day, now.hour, now.minute, now.second)
4
import datetime
now = datetime.datetime.now()
print(now.year, now.month, now.day, now.hour, now.minute, now.second)
do not copy me
-1

New to Communities?

Join the community