If you want just the current date, simply use the today()
method from the date
imported from the datetime
module.
from datetime import date
current_date = date.today()
print(current_date)
2020-05-02
If you want the current date and also the time, use the now()
method from datetime
.
from datetime import datetime
current_datetime = datetime.now()
print(current_datetime)
2020-05-02 11:29:23.993047