Ich habe einige Code, der gut in Python 2.7 funktioniert.Str.format() für Python 2.6 gibt Fehler wo 2,7 nicht
Python 2.7.3 (default, Jan 2 2013, 13:56:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from sys import stdout
>>> foo = 'Bar'
>>> numb = 10
>>> stdout.write('{} {}\n'.format(numb, foo))
10 Bar
>>>
Aber in 2.6 bekomme ich eine ValueError-Ausnahme.
Python 2.6.8 (unknown, Jan 26 2013, 14:35:25)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from sys import stdout
>>> foo = 'Bar'
>>> numb = 10
>>> stdout.write('{} {}\n'.format(numb, foo))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: zero length field name in format
>>>
Wenn durch die Dokumentation (2.6, 2.7) suchen, kann ich nicht erwähnt Änderungen sehen zwischen den beiden Versionen getan wurde. Was passiert hier?
Vielen Dank. Ich war damit beschäftigt, mir nur die Dokumentation der Methode anzuschauen, dass ich den Text am Anfang verpasste. – Mogget