0
What is the function of datetime, str, and timedelta? How this works?
why this doesn't work? import datetime seconds = int(input()) print(str(datetime.timedelta(seconds))) .................... ................... ................. But, this works: import datetime seconds = int(input()) print(str(datetime.timedealta(seconds=seconds)))
1 Answer
+ 1
https://docs.python.org/3/library/datetime.html
timedelta takes arguments in the form of seconds, hours, minutes, days etc. and all of them are optional, so if you don't specify them by keyword then it will take them as their respective positions i.e.
timedelta(100) : means 100 days as first argument is days
But
timedelta(0, 100) : means 0 days 100 seconds