如果我用Python运行以下代码:
from datetime import datetime, timedelta
just_before_midnight = datetime(2014, 7, 16, 11, 59, 59)
print just_before_midnight
skip_midnight = timedelta(seconds=2)
just_after_midnight_the_next_day = just_before_midnight + skip_midnight
print just_after_midnight_the_next_day
... 它提供以下输出:
2014-07-16 11:59:59 2014-07-16 12:00:01
有人能解释为什么两种情况下的日期都是7月16日,而不是7月17日?你知道吗
因为那是上午11:59:59。你知道吗
您需要使用24小时的时间来查看预期的结果:
相关问题 更多 >
编程相关推荐