给定字符串开始和结束日期/时间以及我要计算其间时间的间隔数:
import datetime
from datetime import timedelta
Start = '16 Sep 2016 00:00:00'
Stop= '16 Sep 2016 06:00:00.00'
ScenLength = 21600 # in seconds (21600 for 6 hours; 18000 for 5 hours; 14400 for 4 hours)
stepsize = 10 # seconds
Intervals = ScenLength/stepsize
如何创建这些日期和时间的列表?你知道吗
我是Python新手,到目前为止没有太多:
TimeList=[]
TimeSpan = [datetime.datetime.strptime(Stop,'%d %b %Y %H:%M:%S')-datetime.datetime.strptime(Start,'%d %b %Y %H:%M:%S')]
for m in range(0, Intervals):
...
TimeList.append(...)
谢谢!你知道吗
如果我没听错的话,你想找一个固定间隔的时间戳。你知道吗
这可以通过Python类datetime.timedelta完成:
编辑:完整示例
相关问题 更多 >
编程相关推荐