LoginSignup
0
0

More than 1 year has passed since last update.

python 時間取得

Last updated at Posted at 2022-12-10

目的:pythonで時間を取得し、見やすい形に直す
環境:Python 3.10.2 datetime 4.7 pytz 2022.5
下の実行結果:12月10日 20:17

#ライブラリのインポート
import datetime
import pytz

#時刻の取得(年-月-日 時:分:秒.マイクロ秒)
time=datetime.datetime.now(pytz.timezone('Asia/Tokyo'))

#見やすい形に変更(○○月○○日 00:00)
time=time.strftime('%m月%d日 %H:%M')

print(time)
0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0