How to convert string to datetime in python
Question: I have a date string in following format 2011-03-07 how to convert this to
datetime in python?


Answer: Try the following code, which uses `strptime` from the [datetime
module](http://docs.python.org/library/datetime.html):

    
    
    from datetime import datetime
    datetime.strptime('2011-03-07','%Y-%m-%d')
    

I note that this (and many other solutions) are trivially easy to find with
Google ;)

