What\'s the best way to print log lines that match a datetime range. For example:
I would like to print only lines with dates from: 2012/09/30-00:00:10 to: 2012/09/
Actullay, the log format allows to compare date strings without their conversion to datetime.
datetime
with open('mylog.log','r') as f: for line in f: d = line.split(" ",1)[0] if d >= '2012/09/30-00:00:10' and d <= '2012/09/30-00:00:13': print line