回答編集履歴
4
誤植修正
test
CHANGED
@@ -46,7 +46,7 @@
|
|
46
46
|
|
47
47
|
**■代替手段**
|
48
48
|
|
49
|
-
|
49
|
+
[日付の加算 減算](http://python.civic-apps.com/timedelta/)
|
50
50
|
|
51
51
|
[If you need just the seconds...](https://stackoverflow.com/questions/25888726/python-error-unsupported-operand-types-for-int-and-datetime-timedelta)
|
52
52
|
|
3
日本語の修正
test
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
[Python公式](https://docs.python.org/3.6/library/datetime.html#module-datetime)の"Supported operations"に代入演算子(Overload operator)が書かれていませんので、恐らくできないものと思います。
|
4
4
|
|
5
5
|
|
6
|
+
|
7
|
+
参考)エラーの再現
|
6
8
|
|
7
9
|
```Python
|
8
10
|
|
2
コード追加
test
CHANGED
@@ -1,6 +1,44 @@
|
|
1
1
|
**■公式の解説ページ**
|
2
2
|
|
3
3
|
[Python公式](https://docs.python.org/3.6/library/datetime.html#module-datetime)の"Supported operations"に代入演算子(Overload operator)が書かれていませんので、恐らくできないものと思います。
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
```Python
|
8
|
+
|
9
|
+
# -*- coding: utf-8 -*-
|
10
|
+
|
11
|
+
import time
|
12
|
+
|
13
|
+
import datetime
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
time_now = time.time()
|
18
|
+
|
19
|
+
print("time.time(): %s"% time_now )
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
time_now = time.time()+10
|
24
|
+
|
25
|
+
print("time.time()+10: %s"% time_now )
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
time_now +=10
|
30
|
+
|
31
|
+
print("time_now+=10: %s"% time_now )
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
time_now +=datetime.timedelta(hours=1)
|
36
|
+
|
37
|
+
# TypeError: unsupported operand type(s) for +=: 'float' and 'datetime.timedelta'
|
38
|
+
|
39
|
+
print("time_now +=datetime.timedelta(hours=1): %s"% time_now )
|
40
|
+
|
41
|
+
```
|
4
42
|
|
5
43
|
|
6
44
|
|
1
補足追加
test
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
+
**■公式の解説ページ**
|
2
|
+
|
3
|
+
[Python公式](https://docs.python.org/3.6/library/datetime.html#module-datetime)の"Supported operations"に代入演算子(Overload operator)が書かれていませんので、恐らくできないものと思います。
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
**■代替手段**
|
8
|
+
|
1
|
-
[日付の加算 減算](http://python.civic-apps.com/timedelta/)
|
9
|
+
ボールドテキスト[日付の加算 減算](http://python.civic-apps.com/timedelta/)
|
2
10
|
|
3
11
|
[If you need just the seconds...](https://stackoverflow.com/questions/25888726/python-error-unsupported-operand-types-for-int-and-datetime-timedelta)
|
4
12
|
|
5
13
|
[clock arithmetic](https://stackoverflow.com/questions/12448592/how-to-add-delta-to-python-datetime-time)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
どれも基本的にそのまま数字で換算はできないために、一度何らかの関数を挟んでやる、というスタイルですね。
|