Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.python > #4741
| From | Florian Lindner <mailinglists@xgm.de> |
|---|---|
| Newsgroups | de.comp.lang.python |
| Subject | [Python-de] Warum liefert // ein float? |
| Date | 2017-04-06 09:52 +0200 |
| Message-ID | <mailman.169.1491465173.2961.python-de@python.org> (permalink) |
| References | <ea8deb7d-44d8-4f77-3922-90e41b49a439@xgm.de> |
Hallo, Python 3.6.0 (default, Jan 16 2017, 12:12:55) >>> x = 3.5 >>> y = 2.5 >>> x // y 1.0 >>> type(x // y) <class 'float'> >>> range(x // y) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'float' object cannot be interpreted as an integer Warum liefert // ein float zurück, obwohl das Ergebnis, immer eine eine Ganzzahl ist (in dem Sinne, dass es keine Nachkommestellen hat)? Damit ich da raus eine range machen kann, brauche ich wieder int(.), dann kann ich aber gleich auf // verzichten. Nur mal Interesse halber... Grüße, Florian
Back to de.comp.lang.python | Previous | Next | Find similar
[Python-de] Warum liefert // ein float? Florian Lindner <mailinglists@xgm.de> - 2017-04-06 09:52 +0200
csiph-web