[Tutor] noobie question,,,error related

Noah Hall enalicho at gmail.com
Mon Jan 31 12:46:33 CET 2011


> I get this error when I try and load the datetime module,
>
> Traceback (most recent call last):
>   File "C:/Python27/TIMED_PROGRAM.py", line 2, in <module>
>     datetime.ctime()
> AttributeError: 'module' object has no attribute 'ctime'

Your problem, I guess comes from you having code like the following -

>>>import datetime
>>>datetime.ctime(arg)
Error

The problem with that is that datetime.ctime doesn't exist - it's
datetime.datetime.ctime.
If you want to skip the extra datetime in front, run

>>>from datetime import datetime
>>>datetime.ctime(arg)
Success.

In future, please provide us with code in order to clarify things.


More information about the Tutor mailing list