X



Pythonのお勉強 Part56
■ このスレッドは過去ログ倉庫に格納されています
0878デフォルトの名無しさん
垢版 |
2018/06/16(土) 11:20:55.92ID:eJREzlFG
すいませんめっちゃ初心者なんですけど
>>> "5" + 1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Can't convert 'int' object to str implicitly
>>> "5" - 1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'str' and 'int'
こんな感じで
"5" + 1と"5" - 1という非常に類似した二つの「異なる型どうしの操作で起こるエラー」が
全く違うエラー内容になるのはなぜですかね。
Python3です。
■ このスレッドは過去ログ倉庫に格納されています

ニューススポーツなんでも実況