首页 > 技术文章 > python 获取当前时间 和 前天 or 后天的方法

zhangshijiezsj 2021-08-25 17:58 原文

>>> import datetime
>>> today=datetime.date.today()
>>> print today
2018-01-17
>>> formatted_today=today.strftime('%y%m%d')
>>> print formatted_today
180117
>>> yesterday=int(formatted_today)-1
>>> print yesterday
180116
————————————————
版权声明:本文为CSDN博主「waiwai3」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/waiwai3/article/details/79091118

  

推荐阅读