Feste Anzahl von Nachkommastellen in Python
📁 Python, KI
Gibt es ein Analogon zur Funktion toFixed() in JS? Ich brauche so etwas:
>>> a = 12.3456789
>>> a.toFixed(2)
'12.35'
>>> a.toFixed(0)
'12'
>>> b = 12.000001
>>> b.toFixed(3)
'12.000'
ProgerLib Python für alle
📁 Python, KI
Gibt es ein Analogon zur Funktion toFixed() in JS? Ich brauche so etwas:
>>> a = 12.3456789
>>> a.toFixed(2)
'12.35'
>>> a.toFixed(0)
'12'
>>> b = 12.000001
>>> b.toFixed(3)
'12.000'