0
 for x in range(1.11):
    print ('Number: {0:2d} Square: {1:3d} Cube: {2:4d}'.format(x, x*x, x*x*x))

Traceback (most recent call last):
  File "<pyshell#8>", line 1, in <module>
    for x in range(1.11):
TypeError: 'float' object cannot be interpreted as an integer
4

1 回答 1

0

您使用 a.而不是 a ,infor x in range(1.11):它应该是:

for x in range(1,11):
    print ('Number: {0:2d} Square: {1:3d} Cube: {2:4d}'.format(x, x*x, x*x*x))
于 2013-11-07T14:53:22.400 回答