我使用箭头模块来处理Python中的datetime对象。如果我得到这样的时间:
now = arrow.now()...how我要把它增加一天吗?
发布于 2016-06-09 16:08:25
2020年更新-07-28
增长日
now.shift(days=1)缩减日
now.shift(days=-1)原始答案
截至2019年-08-09年被否决
https://arrow.readthedocs.io/en/stable/releases.html
增长日
now.replace(days=1)缩减日
now.replace(days=-1)发布于 2019-03-26 20:27:57
文档声明shift将用于添加偏移量:
now.shift(days=1)
带有参数(如days、hours、minutes等)的hours方法似乎与shift一样工作,尽管minutes也有day、hour、minute等参数,用提供的值替换给定字段中的值。
无论如何,我认为now.shift(hours=-1)比now.replace要清楚得多。
发布于 2016-06-09 16:12:23
请参阅文档
now = arrow.now()
oneDayFromNow = now.replace(days+=1)https://stackoverflow.com/questions/37731106
复制相似问题