1import datetime
2
3date_time_str = '2018-06-29 08:15:27.243860'
4date_time_obj = datetime.datetime.strptime(date_time_str, '%Y-%m-%d %H:%M:%S.%f')
5
6print('Date:', date_time_obj.date())
7print('Time:', date_time_obj.time())
8print('Date-time:', date_time_obj)
9
1import datetime
2
3# str value "Apr 2, 2019" convert into any format.
4datetime.datetime.strptime('Apr 2, 2019', '%b %d, %Y').strftime('%a, %d %b %Y')
1>>> import datetime
2>>> datetime.datetime.strptime('03:55', '%H:%M').time()
3datetime.time(3, 55)