我被要求编辑一个脚本,允许您从日志文件中打印出信息的时间窗口。我很难弄清楚什么才是最好的方式。日志在日志开始处的时间如下:
[11-Oct-2012 07:41:22.205608我需要能够按小时、分钟或秒来缩小范围。我不关心日期、月份或年份。
发布于 2012-10-16 02:42:31
import datetime
datetime.datetime.strptime("11-Oct-2012 07:41:22.205608", "%d-%b-%Y %H:%M:%S.%f")就是这样做的。
http://docs.python.org/library/datetime.html#datetime.datetime.strptime -返回与date_string对应的datetime,按照格式解析...
https://stackoverflow.com/questions/12901600
复制相似问题