4 odpowiedzi
+ 7
from datetime import datetime
# both time & date
print(datetime.now())
# only date
print(datetime.now().date())
# only time
print(datetime.now().time())
# hh:mm:ss AM/PM format
print(datetime.now().strftime("%I:%M:%S %p"))
Check out the docs for more:
https://docs.python.org/3/library/datetime.html
+ 6
Kishalaya has answered well, just notice that on SoloLearn, the time will be of SoloLearn's server but not your device, because codes are executed there and then return the result to ours
+ 1
You're welcome, Skrub !
0
thanks