teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

bsdfanさんのご指摘を反映

2021/02/12 04:12

投稿

ppaul
ppaul

スコア24672

answer CHANGED
@@ -1,4 +1,5 @@
1
+ bsdfanさんご指摘を反映しました。
1
- ようてください。
2
+ 秒数が30場合切り上げずに切り下げられいますが、ご容赦ください。
2
3
 
3
4
  ```python
4
5
  >>> import datetime
@@ -6,7 +7,15 @@
6
7
  >>> print(total_minutes)
7
8
  1 day, 12:00:00
8
9
  >>> seconds = int(total_minutes.total_seconds())
9
- >>> hm = '%d:%02d' % (seconds//3600, seconds%3600)
10
+ >>> hm = '%d:%02d' % (seconds//3600, round(seconds%3600/60))
10
11
  >>> print(hm)
11
12
  36:00
13
+ >>>
14
+ >>> total_minutes = datetime.timedelta(days=1, hours=12, minutes=20, seconds=31)
15
+ >>> print(total_minutes)
16
+ 1 day, 12:20:31
17
+ >>> seconds = int(total_minutes.total_seconds())
18
+ >>> hm = '%d:%02d' % (seconds//3600, round(seconds%3600/60))
19
+ >>> print(hm)
20
+ 36:21
12
21
  ```