此python输出格式代码的解释

问题描述 投票:0回答:2

此代码的作用是什么?

for x in range(1,11):
    print('{0:2d} {1:3d} {2:4d}'.format(x,x**2,x**3))
python output
2个回答
4
投票
0: | 1: | 2: => The position in the arg list from which to get the value. The order can be anything you want, and you can repeat values, e.g. '{2:...} {0:...} {1:...} {0:...}' 2 | 3 | 4 => The minimum width of the field in which to display the value. Right justified by default for numbers. d => The value must be an integer and it will be displayed in base 10 format (v. hex, octal, or binary format)

2
投票
让我们变得更简单:
© www.soinside.com 2019 - 2024. All rights reserved.