The optional argument sep (default 'T') is a one-character separator, placed between the date and time portions of the result. For example:
>>> import datetime as dt>>> class TZ(dt.tzinfo):... """A time zone with an arbitrary, constant -06:39 offset."""... def utcoffset(self, when):... return dt.timedelta(hours=-6, minutes=-39)...>>> dt.datetime(2002, 12, 25, tzinfo=TZ()).isoformat(' ')'2002-12-25 00:00:00-06:39'>>> dt.datetime(2009, 11, 27, microsecond=100, tzinfo=TZ()).isoformat()'2009-11-27T00:00:00.000100-06:39'
The optional argument timespec specifies the number of additional components of the time to include (the default is 'auto'). It can be one of the following:
'auto': Same as 'seconds' if microsecond is 0, same as 'microseconds' otherwise.
'hours': Include the hour in the two-digit HH format.
'minutes': Include hour and minute in HH:MM format.
'seconds': Include hour, minute, and second in HH:MM:SS format.
'milliseconds': Include full time, but truncate fractional second part to milliseconds. HH:MM:SS.sss format.
'microseconds': Include full time in HH:MM:SS.ffffff format.
Note: Excluded time components are truncated, not rounded.
ValueError will be raised on an invalid timespec argument: