【发布时间】:2017-11-24 19:27:35
【问题描述】:
我有两次,我想在 Python 中使用相同的格式列出它们之间的所有时间
from= '2016-12-02T11:00:00.000Z'
to= '2017-06-06T07:00:00.000Z'
hours=to-from
所以结果会是这样的 2016-12-02T11:00:00.000Z 2016-12-02T12:00:00.000Z 2016-12-02T13:00:00.000Z ..... 等等 我该怎么做?我应该使用什么样的插件?
【问题讨论】:
-
from datetime import timedelta。应该有帮助。 -
from是一个内置词 -
您不能减去
str对象,请改用datetime对象 -
结果范围应包括
to? -
我们是否应该截断分钟/秒/...如果它们不为零?
标签: python python-2.7 date time datetime-format