Python 2.5.2 で次のコードを実行すると:
for x in range(1, 11):
print '{0:2d} {1:3d} {2:4d}'.format(x, x*x, x*x*x)
私は得る:
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'
問題がわかりません。
そこから属性dir('hello')
はありません。format
どうすればこれを解決できますか?