【时空数据挖掘】Python的时间处理
- 字符串转类:
time.srtptime
import time
time_str = "2022-03-18 10:54:00"
struct_time = time.strptime(time_str, '%Y-%m-%d %H:%M:%S')
print(struct_time)
- 类转时间戳:
time.mktime
- 时间戳是int,是1970年1月1日的偏移量
timestamp = time.mktime(struct_time)
print(timestamp)
- 类转字符串:
time.strftime
参考文献:
https://blog.csdn.net/brucewong0516/article/details/79044905
https://blog.csdn.net/weixin_41888257/article/details/123569910