0
0

日時データの変換その2 (paizaランク C 相当)

Posted at

日時が "yyyy/MM/dd hh:mm" の形式で与えられるので、年・月・日・時・分をそれぞれ出力してください。(ただし、足りない部分は0埋めすること)

以前習ったfstringが活躍する。
書き方忘れてたかもなので復習する

date, time = map(str,input().split())
yyyy, MM, dd = map(str,date.split('/'))
hh, mm = map(str,time.split(':'))
print(f"{yyyy:0>4}")
print(f"{MM:0>2}")
print(f"{dd:0>2}")
print(f"{hh:0>2}")
print(f"{mm:0>2}")
0
0
0

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