In [1]:
import datetime
In [2]:
d = datetime.date(2018, 12, 31)
In [3]:
print(d)
In [4]:
print(type(d))
In [5]:
print(d.isoformat())
In [6]:
print(type(d.isoformat()))
In [7]:
t = datetime.time(5, 0, 30, 1000)
In [8]:
print(t)
In [9]:
print(type(t))
In [10]:
print(t.isoformat())
In [11]:
print(type(t.isoformat()))
In [12]:
print(t.isoformat('hours'))
In [13]:
print(t.isoformat('minutes'))
In [14]:
print(t.isoformat('seconds'))
In [15]:
print(t.isoformat('milliseconds'))
In [16]:
print(t.isoformat('microseconds'))
In [17]:
dt = datetime.datetime(2018, 12, 31, 5, 0, 30, 1000)
In [18]:
print(dt)
In [19]:
print(type(dt))
In [20]:
print(dt.isoformat())
In [21]:
print(type(dt.isoformat()))
In [22]:
print(dt.isoformat(' '))
In [23]:
print(dt.isoformat('x'))
In [24]:
# print(dt.isoformat('xx'))
# TypeError: isoformat() argument 1 must be a unicode character, not str
In [25]:
print(dt.isoformat(timespec='hours'))
In [26]:
print(dt.isoformat(timespec='minutes'))
In [27]:
print(dt.isoformat(timespec='seconds'))
In [28]:
print(dt.isoformat(timespec='milliseconds'))
In [29]:
print(dt.isoformat(timespec='microseconds'))
In [30]:
print(dt.isoformat(' ', 'seconds'))
In [31]:
print(dt.date())
In [32]:
print(type(dt.date()))
In [33]:
print(dt.date().isoformat())
In [34]:
print(type(dt.date().isoformat()))
In [35]:
print(dt.time())
In [36]:
print(type(dt.time()))
In [37]:
print(dt.time().isoformat())
In [38]:
print(type(dt.time().isoformat()))
In [39]:
print(dt.time().isoformat('seconds'))