get yesterday's date in python

You can use the datetime module in Python to get yesterday's date. Here's an example:

main.py
from datetime import date, timedelta

yesterday = date.today() - timedelta(days=1)
print(yesterday)
100 chars
5 lines

This will output yesterday's date in the format YYYY-MM-DD.

gistlibby LogSnag