1
GTim 2017-07-09 09:48:04 +08:00
```python
s = ["{:0>2}:{:0>2}".format(i/60,i%60) for i in range(0,86400,5)] ``` |
3
hxsf 2017-07-09 09:50:51 +08:00
[str(x) + ':' + str(y) for x in range(0, 24) for y in range(0, 60, 5)] 用推导式啊。。。
|
4
hsmocc 2017-07-09 10:21:44 +08:00 via iPhone 1
["%02d:%02d" %(h,m) for h in range(0, 24) for m in range(0, 60, 5)]
|
5
staticor 2017-07-09 11:09:32 +08:00
如果用过 Pandas 的话有方便的时间序列函数.
```python import pandas as pd pd.date_range('2017-01-01 01:00:00', '2017-01-01 02:00:00', freq= '5min') ``` |
6
Hieast 2017-07-09 11:11:17 +08:00 via Android
arrow 也有专门的时间序列函数
|
7
hand515 2017-07-09 13:50:15 +08:00
if len(str(y)) == 1:
为啥不直接 if y< 10: 呢。 |
8
raiz 2017-07-09 16:42:10 +08:00
seq = ["%02d:%02d" %(i, j) for i in range(0,24) for j in range(0,60,5)]
|
9
hugo775128583 2017-07-09 16:44:02 +08:00 via Android
你需要 rrule
|
10
mckelvin 2017-07-10 09:17:45 +08:00
```
import datetime start_dt = datetime.datetime(2017, 1, 1) interval = datetime.timedelta(seconds=300) for i in range(24 * 12): print (start_dt + interval * i).strftime("%H:%M") ``` |
12
hwsdien 2017-07-10 11:37:43 +08:00
import arrow
start, end = arrow.now().span('day') print [repr(r) for r in arrow.Arrow.range('minute', start, end) if r.minute % 5 == 0] |
13
xuzixx1001 2017-07-10 16:00:59 +08:00
9 楼+1 dateutil rrule
|