[Python] NameError: name 'datetime' is not defined

Discussão em 'Python' iniciado por Stack, Março 16, 2025.

  1. Stack

    Stack Membro Participativo

    I'm teaching myself Python and was just "exploring". Google says that datetime is a global variable but when I try to find todays date in the terminal I receive the NameError in the question title?

    mynames-MacBook:pythonhard myname$ python
    Enthought Canopy Python 2.7.3 | 64-bit | (default, Aug 8 2013, 05:37:06)
    [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> date = datetime.date.today()
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    NameError: name 'datetime' is not defined
    >>>

    Continue reading...

Compartilhe esta Página