2025年python代码获取今天、昨天、明天的日期

python代码获取今天、昨天、明天的日期python 代码获取今天 昨天 明天的日期 python 代码获取今天 昨天 明天的日期 Python program to find yesterday today and tomorrow Import datetime and timedelta class from datetime module from datetime

大家好,我是讯享网,很高兴认识大家。

python代码获取今天、昨天、明天的日期

 

See the source image
讯享网

#python代码获取今天、昨天、明天的日期

# Python program to find yesterday, # today and tomorrow # Import datetime and timedelta # class from datetime module from datetime import datetime, timedelta # Get today's date presentday = datetime.now() # or presentday = datetime.today() # Get Yesterday yesterday = presentday - timedelta(1) # Get Tomorrow tomorrow = presentday + timedelta(1) # strftime() is to format date according to # the need by converting them to string print("Yesterday = ", yesterday.strftime('%d-%m-%Y')) print("Today = ", presentday.strftime('%d-%m-%Y')) print("Tomorrow = ", tomorrow.strftime('%d-%m-%Y')) 

讯享网
讯享网Yesterday = 13-06-2021 Today = 14-06-2021 Tomorrow = 15-06-2021

 

参考:Python | Find yesterday’s, today’s and tomorrow’s date

参考:Find yesterday’s, today’s and tomorrow’s date in Python

 

小讯
上一篇 2025-03-04 12:58
下一篇 2025-02-16 07:14

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/116115.html