not getting date time from correctly formatted string

I’m using this code to get the time from lines in a file.

    for line in f:
            dt = parser.parse(line).replace(tzinfo=None)
            print dt
        except Exception, e:

Nothing is printed out, and line are of the form
"Fri May 15 11:22:54 EDT 2015" (generated by date command). When I do

parser.parse("Fri May 15 11:22:54 EDT 2015").replace(tzinfo=None)

directly, I get the correct result.

Source: python

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.