{"id":11843,"date":"2022-02-06T16:01:12","date_gmt":"2022-02-06T21:01:12","guid":{"rendered":"http:\/\/local.brightwhiz\/?post_type=snippets&p=11843"},"modified":"2022-02-06T16:42:52","modified_gmt":"2022-02-06T21:42:52","slug":"how-to-get-current-year-python","status":"publish","type":"snippets","link":"http:\/\/local.brightwhiz\/snippets\/how-to-get-current-year-python\/","title":{"rendered":"Get the Current Year in Python"},"content":{"rendered":"\n
Using DateTime:<\/p>\n\n\n\n
import datetime\nnow = datetime.datetime.now().year\nprint(now)<\/code><\/pre>\n\n\n\nor:<\/p>\n\n\n\n
from datetime import date\nyear = date.today().year\nprint(year)<\/code><\/pre>\n","protected":false},"comment_status":"open","ping_status":"closed","template":"","meta":[],"categories":[953,15],"tags":[954,471,475],"yoast_head":"\nHow to Get the Current Year in Python<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n