Python 中的 TimeTuple 是什么?
pythonserver side programmingprogramming
Python 的许多时间函数将时间处理为 9 个数字的元组,如下所示 −
Index | Field | Values |
---|---|---|
0 | 4-digit year | 2008 |
1 | Month | 1 to 12 |
2 | Day | 1 to 31 |
3 | Hour | 0 to 23 |
4 | Minute | 0 to 59 |
5 | Second | 0 to 61 (60 or 61 are leap-seconds) |
6 | Day of Week | 0 to 6 (0 is Monday) |
7 | Day of year | 1 to 366 (Julian day) |
8 | Daylight savings | -1, 0, 1, -1 means library determines DST |
上述元组相当于 struct_time 结构。此结构具有以下属性 −
Index | Attributes | Values |
---|---|---|
0 | tm_year | 2008 |
1 | tm_mon | 1 to 12 |
2 | tm_mday | 1 to 31 |
3 | tm_hour | 0 to 23 |
4 | tm_min | 0 to 59 |
5 | tm_sec | 0 to 61 (60 or 61 are leap-seconds) |
6 | tm_wday | 0 to 6 (0 is Monday) |
7 | tm_yday | 1 to 366 (Julian day) |
8 | tm_isdst | -1, 0, 1, -1 means library determines DST |