[Python][メモ]feedparserを使用して自分用RSSリーダーなどを作成中。詰まったところなどメモ。

ドキュメント→feedparser 5.2.0 documentation

 

‘updated’や’updated_parsed’で日付を操作・制御

updatedは更新日時の文字列。

 

 

updated_parsedtime.struct_timeオブジェクト。扱いやすい基本的な日付型datetimeに変換する必要があった。

参考URL→time.struct_timeオブジェクトをどのようにしてdatetimeオブジェクトに変換しますか?

 

実行結果

time.struct_time(tm_year=2020, tm_mon=8, tm_mday=26, tm_hour=11, tm_min=0, tm_sec=56, tm_wday=2, tm_yday=239, tm_isdst=0)

 

実行結果

2020/08/26

 

日付の足し算・引き算

timedelta()メソッドを使用

実行結果(昨日の日付になる)

2020-09-01 07:31:58.750095

 

タイトルとURLをコピーしました