format - String formatting in Python version earlier than 2.6 -


When I run the following code in Python 2.5.2:

  For (1, 11): Print '{0: 2d} {1: 3d} {2: 4d}'. Format (x, x * x, x * x * x)  

I get:

  traceback (most recent call final): File " & Lt; pyshell # 9 "gt; Line 2, & lt; Module & gt; Print '{0: 2d} {1: 3d} {2: 4d}'. Format (x, x * x, x * x * x) Attribute Enter: 'str' object has no attribute 'format'  <
 

I do not understand the problem.

to dir ('hello') is not a format attribute.

How can I solve it?

str.format method was Python 2.6 and later.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -