2014-02-10 60 views
0

學習使用python進行編碼我被卡住得到datetime未定義的錯誤。我在codecademy上搜索了所有內容,沒有看到我的代碼錯在哪裏......對於我的新手提前感到抱歉,並感謝您的幫助。未在codecademy上定義新手python datetime

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) 

回答

1

應該

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

改變你的進口:

from datetime import datetime