Python beheben: ValueError: unsupported format character ' ' (0x20) at index 3
English
Deutsch
Problem:
Man versucht, Python-Formatstrings zu verwenden wie
format_string_example.py
"Hello %.3 world" % 1.234aber man sieht eine Fehlermeldung wie
valueerror_traceback.txt
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-4-7cbe94e4525d> in <module>
----> 1 "Hello %.3 world" % 1.234
ValueError: unsupported format character ' ' (0x20) at index 9Lösung
Der Formatstring %.3 ist unvollständig! Man muss den Typ des zu formatierenden Wertes angeben, z.B. f für Fließkomma, d für Ganzzahlen, s für Strings etc. Also anstelle von %.3 %.3f schreiben, oder anstelle von nur % z.B. %f, %d oder %s schreiben, je nach Datentyp der Variable, die dort eingefügt werden soll.
Check out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow