import datetime s = 'December 8, 2016' ss=datetime.datetime.strptime(s.strip(), '%B %d, %Y') print(ss)