import time as t
now=t.localtime()
print('localtime()')
print(now)
print()
print("t.strftime('%y-%m-%d %H:%M:%S',now)")
print(t.strftime('%y-%m-%d %H:%M:%S',now))
import datetime as dt
nowdt= dt.datetime.now()
print()
print('nowdt')
print(nowdt)
print('nowdt.isoformat()')
print(nowdt.isoformat())
nextyear=dt.datetime(2022,1,1)
print()
print('delta.days')
delta=nextyear-nowdt
print(delta.days)
==== RESTART: C:/python/time&datetimeTest.py ===
localtime()
time.struct_time(tm_year=2021, tm_mon=2, tm_mday=28, tm_hour=10,
tm_min=37, tm_sec=53, tm_wday=6, tm_yday=59, tm_isdst=0)
t.strftime('%y-%m-%d %H:%M:%S',now)
21-02-28 10:37:53
nowdt
2021-02-28 10:37:53.398604
nowdt.isoformat()
2021-02-28T10:37:53.398604
delta.days
306
>>>
コメント
コメントを投稿