Home » Python » datetime・date・timeの属性比較一覧

datetime・date・timeの属性比較一覧

動作検証バージョン:Windows 11 Home + Python 3.10.11

『Excel VBAユーザーのためのPythonプログラミング入門』p.168より

拙著『Excel VBAユーザーのためのPyhonプログラミング入門』の、「第9章-03 datetimeモジュールで今日の日付を取得する」でPythonで日付や時刻を処理するときに使用するdatetimeモジュールについて少しだけ解説しています。

Pythonのdatetimeモジュールに用意されている、datetimeクラスは、基本的にはdateクラスとtimeクラスをマージしたものですが、微妙な違いもあります。

[スポンサードリンク]

それぞれがどのような属性を持っているかを比較するための一覧を作成しておきます。

datetimeクラスdateクラスtimeクラス
astimezone--
combine--
ctimectime-
date--
dayday-
dst-dst
fold-fold
fromisocalendarfromisocalendar-
fromisoformatfromisoformatfromisoformat
fromordinalfromordinal-
fromtimestampfromtimestamp-
hour-hour
isocalendarisocalendar-
isoformatisoformatisoformat
isoweekdayisoweekday-
maxmaxmax
microsecond-microsecond
minminmin
minute-minute
monthmonth-
now--
replacereplacereplace
resolutionresolutionresolution
second-second
strftimestrftimestrftime
strptime--
time--
timestamp--
timetupletimetuple-
timetz--
todaytoday-
toordinaltoordinal-
tzinfo-tzinfo
tzname-tzname
utcfromtimestamp--
utcnow--
utcoffset-utcoffset
utctimetuple--
weekdayweekday-
yearyear-

[スポンサードリンク]

Home » Python » datetime・date・timeの属性比較一覧

「Python」の記事一覧

検索

Copyright © インストラクターのネタ帳 All Rights Reserved.

.