1from datetime import datetime
2
3datetime_str = '09/19/18 13:55:26'
4
5datetime_object = datetime.strptime(datetime_str, '%m/%d/%y %H:%M:%S')
6
7print(type(datetime_object))
8print(datetime_object) # printed in default format
9
1date_str = '09-19-2018'
2
3date_object = datetime.strptime(date_str, '%m-%d-%Y').date()
4print(type(date_object))
5print(date_object) # printed in default formatting
6