0
Python: Datetime
Greetings, I have a problem with datetime in Python. Why does the below code block fail? from datetime import datetime print datetime.now() BUT This one runs successfully? from datetime import datetime now = datetime.now() print (now) print (now.year) print (now.month) print (now.day)
6 Antworten
+ 4
Put a bracket after 'print'.
Its working for me.
+ 3
Adam Haller Yes
Edit: But you can write it in this way too.
import datetime
print(datetime.datetime.now())
+ 2
print(datetime.now()) will work
+ 2
thank you very much guyss
+ 1
Thank you very much... Pranav Kalro , so, do i also need to put from datetime?
0
Version of python is changed from python2 to python3. So we have to use paranthesis after print function. print()