回答編集履歴

7

データ変更

2020/01/30 09:26

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  ```python
8
8
 
9
- timelists = ["14:34:26.602", "14:34:06.602", "14:34:59.950", "23:59:59.999"]
9
+ timelists = ["14:34:26.602", "14:34:06.602", "14:04:59.950", "23:59:59.999"]
10
10
 
11
11
  time2lists = []
12
12
 
@@ -40,6 +40,6 @@
40
40
 
41
41
  ```
42
42
 
43
- ['14:34:26:6', '14:34:06:6', '14:35:00:0', '00:00:00:0']
43
+ ['14:34:26:6', '14:34:06:6', '14:05:00:0', '00:00:00:0']
44
44
 
45
45
  ```

6

実行結果追記

2020/01/30 09:26

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -31,3 +31,15 @@
31
31
  print(time2lists)
32
32
 
33
33
  ```
34
+
35
+
36
+
37
+ 実行結果
38
+
39
+
40
+
41
+ ```
42
+
43
+ ['14:34:26:6', '14:34:06:6', '14:35:00:0', '00:00:00:0']
44
+
45
+ ```

5

特殊データに置き換え

2020/01/30 07:44

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  ```python
8
8
 
9
- timelists = ["14:34:26.602", "14:34:26.668", "14:34:06.602", "23:59:59.999"]
9
+ timelists = ["14:34:26.602", "14:34:06.602", "14:34:59.950", "23:59:59.999"]
10
10
 
11
11
  time2lists = []
12
12
 

4

import 削除

2020/01/30 07:42

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -5,10 +5,6 @@
5
5
 
6
6
 
7
7
  ```python
8
-
9
- from datetime import datetime
10
-
11
-
12
8
 
13
9
  timelists = ["14:34:26.602", "14:34:26.668", "14:34:06.602", "23:59:59.999"]
14
10
 

3

23:59:59.999 に対応

2020/01/30 07:27

投稿

shiracamus
shiracamus

スコア5406

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

2

説明変更

2020/01/30 07:21

投稿

shiracamus
shiracamus

スコア5406

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

1

修正中

2020/01/30 06:50

投稿

shiracamus
shiracamus

スコア5406

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