Pergunta

learning to code with python I'm stuck getting datetime not defined error. Im on codecademy googled all around and not seeing where my code is wrong...sorry for my newbieness in advance and thanks for your help.

Instructions:
Print the current date in the form of mm/dd/yyyy. 

my code:

import datetime
now = datetime.now()
print now

current_month = now.month
current_day = now.day
current_year = now.year


print str(current_month)+"/"+str(current_day)+"/"+str(current_year)
Foi útil?

Solução 2

It should be

import datetime
now = datetime.datetime.now()
print now

Outras dicas

change your import to:

from datetime import datetime
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top