大话西游666
0.2f中"."前面的数字表示这个数字要占有多少个字节,“0”表示不刻意规定占用字节数,只要能表示这个数字就行。而“.”后面的数字表示小数位数。d表示这个数据类型是整型,还有s表示数据类型是字符串。以下是我们python教材中的原话,供你参考:>>> "Hello %s %s, you may have won $%d!" % ("Mr.", "Smith", 10000)’Hello Mr. Smith, you may have already won $10000!’>>> ’This int, %5d, was placed in a field of width 5’ % (7)’This int, 7, was placed in a field of width 5’>>> ’This int, %10d, was placed in a field of width 10’ % (7)’This int, 7, was placed in a field of width 10’>>> ’This float, %10.5f, has width 10 and precision 5.’ % (3.1415926)’This float, 3.14159, has width 10 and precision 5.’>>> ’This float, %0.5f, has width 0 and precision 5.’ % (3.1415926)’This float, 3.14159, has width 0 and precision 5.’>>> "Compare %f and %0.20f" % (3.14, 3.14)’Compare 3.140000 and 3.14000000000000012434’