Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
どちらが優先されますか? もしそうなら、すべての場合ですか、それともほんの一部ですか?
日付と時刻のデータの長いリストを保持するために、何らかの形式の日付クラスを使用するつもりです'2009-01-01 10:12:00'。
'2009-01-01 10:12:00'
struct_time は時間を表す古い方法で、C 標準ライブラリをモデルにしています。datetime は後で来て、よりPythonicで、より機能的で、struct_time関数よりもエッジケースでより予測可能な動作をします. 測定されたパフォーマンスの差が問題になるほど重大な場合や、コードの可読性が大幅に低下する場合を除いて、私は datetime を使用します。
datetimeはよりオブジェクト指向であり、timedelta-objects を使用した演算など、多くの便利な機能を提供します。
datetime
timedelta