回答編集履歴
2
誤植修正
test
CHANGED
@@ -32,9 +32,11 @@
|
|
32
32
|
|
33
33
|
# print("hour:" + str_date[8:10])
|
34
34
|
|
35
|
-
# print("mnute:" + str_date[10:12])
|
35
|
+
# print("minute:" + str_date[10:12])
|
36
36
|
|
37
|
+
# print("second:" + str_date[12:14])
|
38
|
+
|
37
|
-
# print("
|
39
|
+
# print("float:" + str_date[14:17])
|
38
40
|
|
39
41
|
|
40
42
|
|
1
追記
test
CHANGED
@@ -1 +1,55 @@
|
|
1
1
|
[スライス](https://www.pythonweb.jp/tutorial/string/index11.html)でいけそうですね。
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
---
|
6
|
+
|
7
|
+
**2018/01/03 17:40追記**
|
8
|
+
|
9
|
+
スライスのポイントは2つです。
|
10
|
+
|
11
|
+
- `文字列`から`文字列`をくりぬきます。チョッと回りくどいですが、一度`int`を`str`にしてからです。
|
12
|
+
|
13
|
+
- `スライスする文字列[開始位置:終了位置]`の形式です。開始位置は0から始め、終了位置は1から始めるのと同じ数で指定(0から始めた場合、終了位置は0から始めた数値+1です)します。
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
```Python
|
18
|
+
|
19
|
+
# coding: UTF-8
|
20
|
+
|
21
|
+
int_date = 20161208144911000
|
22
|
+
|
23
|
+
str_date = str(int_date)
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
# print("year:" + str_date[0:4])
|
28
|
+
|
29
|
+
# print("month:" + str_date[4:6])
|
30
|
+
|
31
|
+
# print("day:" + str_date[6:8])
|
32
|
+
|
33
|
+
# print("hour:" + str_date[8:10])
|
34
|
+
|
35
|
+
# print("mnute:" + str_date[10:12])
|
36
|
+
|
37
|
+
# print("mnute:" + str_date[12:17])
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
print(str_date[0:4])
|
42
|
+
|
43
|
+
print(str_date[4:6])
|
44
|
+
|
45
|
+
print(str_date[6:8])
|
46
|
+
|
47
|
+
print(str_date[8:10])
|
48
|
+
|
49
|
+
print(str_date[10:12])
|
50
|
+
|
51
|
+
print(str_date[12:17])
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
```
|