how to get tommorow date with datetime in python

You can use the datetime module to get tomorrow's date. Here's an example code block:

main.py
from datetime import datetime, timedelta

#get today's date
today = datetime.now().date()

#use timedelta to add one day, which gives tomorrow's date
tomorrow = today + timedelta(days=1)

#print tomorrow's date
print(tomorrow)
227 chars
11 lines

This will output tomorrow's date in yyyy-mm-dd format. You can also format the date differently using strftime() method if required.

related categories

gistlibby LogSnag