I'm trying to create a datetime.date object, but change the hyphens in the date to underscores. Is there a way to do this with datetime.date objects? Or would I have to somehow do this with the datetime object?
from datetime import datetime
date = datetime.strptime('2021-12-30', '%Y-%m-%d').date()
print(type(date))
# <class 'datetime.date'>
print(date)
# 2021-12-30
date_2 = date.strftime('%Y_%m_%d')
print(date_2)
# 2021_12_30
print(type(date_2))
# <class 'str'> I want this to stay as a datetime.date object