Wie kann ich zwei Zahlen in Python 2.7 teilen und das Ergebnis mit Dezimalzahlen erhalten?Abteilung in Python 2.7. und 3.3
Ich verstehe es nicht, warum Unterschied gibt es:
in Python 3:
>>> 20/15
1.3333333333333333
in Python 2:
>>> 20/15
1
Ist das nicht ein Modulo eigentlich?
Es ist Integer-Division, yo! '20 mod 15 == 5' –
Versuchen Sie 'float (20)/float (15)' – dumbledad
oder float 20./15. – Tbb