This type of error occurs when the strptime method called on module instead of class:
If your import statement is like below :
If your import statement is like below :
import datetime
Then you need to access strptime method like below:
datetime.datetime.strptime(date, "%Y-%m-%d")
to access the strptime method. Or, you could change the import statement to this:
from datetime import datetime
and access it as you are.
The people who made the
datetime
module also named their class datetime
:#module class method
datetime.datetime.strptime(date, "%Y-%m-%d")
Ref: https://stackoverflow.com/questions/19480028/attributeerror-datetime-module-has-no-attribute-strptime
No comments:
Post a Comment