The instruction show below code… there is not year/month/date in the time_str, Why it returns ‘1900-01-01 08:00:00’?
time_str = "8:00"
time_dt = dt.datetime.strptime(time_str,"%H:%M")
print(time_dt)
The instruction show below code… there is not year/month/date in the time_str, Why it returns ‘1900-01-01 08:00:00’?
time_str = "8:00"
time_dt = dt.datetime.strptime(time_str,"%H:%M")
print(time_dt)
Because that is its default value. As stated here in Technical detail
For the
datetime.strptime()
class method, the default value is1900-01-01T00:00:00.000
: any components not specified in the format string will be pulled from the default value.
So if you just pass the hour and minute it will set other values by default.