はじめに
超小ネタで恐縮ですが、表記の手順に関して自分用メモとして
コード
# タイムスタンプ取得
from datetime import datetime
from pytz import timezone
utc_now = datetime.now(timezone('UTC'))
jst_now = utc_now.astimezone(timezone('Asia/Tokyo'))
ts = jst_now.strftime("%Y%m%d-%H%M%S")
print(ts)
結果例
20200106-182252
今回は、ユニークなファイル名の一部を作る目的でこのような書式にしましたが、"%Y%m%d-%H%M%S"
の部分を書き換えれば、いろいろなパターンに応用可能です。