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

回答編集履歴

7

データ変更

2020/01/30 09:26

投稿

shiracamus
shiracamus

スコア5406

answer CHANGED
@@ -2,7 +2,7 @@
2
2
  0.1秒単位の整数にしてから処理してみました。
3
3
 
4
4
  ```python
5
- timelists = ["14:34:26.602", "14:34:06.602", "14:34:59.950", "23:59:59.999"]
5
+ timelists = ["14:34:26.602", "14:34:06.602", "14:04:59.950", "23:59:59.999"]
6
6
  time2lists = []
7
7
  for time in timelists:
8
8
  h, m, s = time.split(':')
@@ -19,5 +19,5 @@
19
19
  実行結果
20
20
 
21
21
  ```
22
- ['14:34:26:6', '14:34:06:6', '14:35:00:0', '00:00:00:0']
22
+ ['14:34:26:6', '14:34:06:6', '14:05:00:0', '00:00:00:0']
23
23
  ```

6

実行結果追記

2020/01/30 09:26

投稿

shiracamus
shiracamus

スコア5406

answer CHANGED
@@ -14,4 +14,10 @@
14
14
  time2lists.append(time2)
15
15
 
16
16
  print(time2lists)
17
+ ```
18
+
19
+ 実行結果
20
+
21
+ ```
22
+ ['14:34:26:6', '14:34:06:6', '14:35:00:0', '00:00:00:0']
17
23
  ```

5

特殊データに置き換え

2020/01/30 07:44

投稿

shiracamus
shiracamus

スコア5406

answer CHANGED
@@ -2,7 +2,7 @@
2
2
  0.1秒単位の整数にしてから処理してみました。
3
3
 
4
4
  ```python
5
- timelists = ["14:34:26.602", "14:34:26.668", "14:34:06.602", "23:59:59.999"]
5
+ timelists = ["14:34:26.602", "14:34:06.602", "14:34:59.950", "23:59:59.999"]
6
6
  time2lists = []
7
7
  for time in timelists:
8
8
  h, m, s = time.split(':')

4

import 削除

2020/01/30 07:42

投稿

shiracamus
shiracamus

スコア5406

answer CHANGED
@@ -2,8 +2,6 @@
2
2
  0.1秒単位の整数にしてから処理してみました。
3
3
 
4
4
  ```python
5
- from datetime import datetime
6
-
7
5
  timelists = ["14:34:26.602", "14:34:26.668", "14:34:06.602", "23:59:59.999"]
8
6
  time2lists = []
9
7
  for time in timelists:

3

23:59:59.999 に対応

2020/01/30 07:27

投稿

shiracamus
shiracamus

スコア5406

answer CHANGED
@@ -1,1 +1,19 @@
1
- 23:59:59:999 だったときくいかないので修正中・・・
1
+ 23:59:59:999 に対応するため、手こずりした。
2
+ 0.1秒単位の整数にしてから処理してみました。
3
+
4
+ ```python
5
+ from datetime import datetime
6
+
7
+ timelists = ["14:34:26.602", "14:34:26.668", "14:34:06.602", "23:59:59.999"]
8
+ time2lists = []
9
+ for time in timelists:
10
+ h, m, s = time.split(':')
11
+ t = ((int(h) * 60) + int(m)) * 600 + (int(s.replace('.', '')) + 50) // 100
12
+ time2 = "%02d:%02d:%02d:%d" % ((t // 10 // 60 // 60) % 24,
13
+ (t // 10 // 60) % 60,
14
+ (t // 10) % 60,
15
+ t % 10)
16
+ time2lists.append(time2)
17
+
18
+ print(time2lists)
19
+ ```

2

説明変更

2020/01/30 07:21

投稿

shiracamus
shiracamus

スコア5406

answer CHANGED
@@ -1,1 +1,1 @@
1
- 9.999 だったときにうまくイカないので修正中
1
+ 23:59:59:999 だったときにうまくいかないので修正中・・・

1

修正中

2020/01/30 06:50

投稿

shiracamus
shiracamus

スコア5406

answer CHANGED
@@ -1,10 +1,1 @@
1
- ```python
2
- timelists = ["14:34:26.602","14:34:26.668","14:34:06.602","14:34:06.668"]
3
- time2lists = []
4
- for time in timelists:
1
+ 9.999 だったときにうまくイカないので修正中
5
- f = float(time[7:12])
6
- time2 = time[0:7] + str((round(f, 1)))
7
- time2lists.append(time2)
8
-
9
- print(time2lists)
10
- ```