写一个python获取日期
时间: 2024-02-03 18:04:20 浏览: 67
import datetime
today = datetime.date.today()
print("今天是:", today)
# 获取昨天日期
yesterday = today - datetime.timedelta(days=1)
print("昨天是:", yesterday)
# 获取明天日期
tomorrow = today + datetime.timedelta(days=1)
print("明天是:", tomorrow)
阅读全文