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
答案 0 :(得分:0)
您在.
中使用,
代替for 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))