1
2from datetime import datetime
3
4dt_string = "12/11/2018 09:15:32"
5
6# Considering date is in dd/mm/yyyy format
7dt_object1 = datetime.strptime(dt_string, "%d/%m/%Y %H:%M:%S")
8print("dt_object1 =", dt_object1)
9
10# Considering date is in mm/dd/yyyy format
11dt_object2 = datetime.strptime(dt_string, "%m/%d/%Y %H:%M:%S")
12print("dt_object2 =", dt_object2)
13