It should be
import datetime
now = datetime.datetime.now()
print now
سؤال
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)
المحلول 2
It should be
import datetime
now = datetime.datetime.now()
print now
نصائح أخرى
change your import to:
from datetime import datetime