0
What is the quickest/most straight forward way to print the current date & time in python?
3 Respostas
+ 10
This is the most straightforward way I know:
from datetime import datetime
now = datetime.now()
print(now)
+ 5
Using datetime.now() shows the date but also the time:
>>> print(datetime.now())
2020-06-30 13:20:42.540223
if you only need to have the date, you better use this:
from datetime import date
print(date.today())
result will be:
2020-06-30