The method is datetime.datetime.strptime
, and when you do a simple import datetime
, you are only importing the top level module, not the datetime
class
You can test this out like this:
>>> import datetime
>>> locals()
{'__builtins__': <module '__builtin__' (built-in)>, '__name__': '__main__', 'dat
etime': <module 'datetime' (built-in)>, '__doc__': None, '__package__': None}
>>> from datetime import datetime
>>> locals()
{'__builtins__': <module '__builtin__' (built-in)>, '__name__': '__main__', 'dat
etime': <type 'datetime.datetime'>, '__doc__': None, '__package__': None}
You can see that there are two different objects in your namespace.
For your second question Python's built-in help()
only works for those modules and objects that are loaded. If you didn't import datetime
, help()
can't help you. So its best to browse the documentation for this; and a google on python strptime
generally lands you at the correct documentation page.