1

time.strftime(format[, t])最初のパラメータにはがformatあり、その中にtime.strptime(string[, format])は2番目のパラメータがあります。どうしてこんなことに?時々私は混乱し、エラーを引き起こしたformat最初のパラメータとして 意図せずに使用されました。time.strptime

4

1 に答える 1

1

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.strftime and time.strptime don't support.) Since time.strftime(format) formats the current time, the optional time to use instead of the current time has to be the second argument. And likewise, since time.strptime(string) parses string according to the default format, the format has to be the second argument.

于 2012-02-20T13:29:09.737 に答える