Cuando ejecuto el siguiente código en Python 2.5.2:formato de cadenas en Python versión 2.6 antes de lo
for x in range(1, 11):
print '{0:2d} {1:3d} {2:4d}'.format(x, x*x, x*x*x)
me sale:
Traceback (most recent call last):
File "<pyshell#9>", line 2, in <module>
print '{0:2d} {1:3d} {2:4d}'.format(x, x*x, x*x*x)
AttributeError: 'str' object has no attribute 'format'
No entiendo el problema.
De dir('hello')
no hay ningún atributo format
.
¿Cómo puedo solucionar esto?
Python 2.5.2 ... – user46646
str.format() solo funciona en 2.6+ y py3k –