In time.strftime(format[, t]) the first parameter is format and in time.strptime(string[, format]) it is second parameter. Why is that so? Sometimes i got confused and unintentionally used format as first parameter in time.strptime which raised an error.
In time.strftime(format[, t]) the first parameter is format and in time.strptime(string[, format]) it is
Share
The general principle is that you put required arguments before optional arguments (and indeed you can’t put optional arguments before required arguments only if you were to use keyword arguments, which
time.strftimeandtime.strptimedon’t support.) Sincetime.strftime(format)formats the current time, the optional time to use instead of the current time has to be the second argument. And likewise, sincetime.strptime(string)parsesstringaccording to the default format, theformathas to be the second argument.