Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有一个我设置的变量
now = datetime.datetime.now()
我希望能够设置一个变量 ,它只yesterday需要now并从中减去一天。
yesterday
now
我确信这非常容易,但是我该怎么做呢?
您可以使用datetime.timedelta:
datetime.timedelta
now = datetime.datetime.now() yesterday = now - datetime.timedelta(days=1)