Using the same code as mentioned but still getting error for strptime.Check attached screenshot
Instructor
09914040666 Replied on 16/10/2020
Hey
Kindly please share your code so that it could be checked.
from _datetime import datetime
currentdate = datetime.now()
print(currentdate)
print(type(currentdate))
formattedDate = currentdate.strftime("%Y,%d %b")
print(formattedDate)
date = "28/09/2020"
string_formattedDate = datetime.strptime(date, "%d/%m/%Y")
print(string_formattedDate)
Instructor
09914040666 Replied on 16/10/2020
Hey
Your code is absolutely fine. The error that you are getting is because of the module name. Do not give the module names as same as the exisiting keywords otherwise interpreter starts searching for the attribute in the module made by you. Kindly change the name of your module to something other than datetime, it will run fine.
Sorry I did not get your point, where I need to change the module name, if I am changing datetime module name then it showing me error.Can you please share code for this.
from _datetime import datetime
currentdate = datetime.now()
print(currentdate)
print(type(currentdate))
formattedDate = currentdate.strftime("%Y,%d %b")
print(formattedDate)
date = "28/09/2020"
string_formattedDate = datetime.strptime(date, "%d/%m/%Y")
print(string_formattedDate)
where I need to change?
Instructor
09914040666 Replied on 17/10/2020
Hey
The code is correct, the name of the file is to be changed. You have the filename for this code as "datetime", change it to something else.
okay, issue has been resolved.Thanks
Instructor
09914040666 Replied on 20/10/2020
Hey
Thank you for the update.