格式代码
A
ABC
ABCDEFGH
%S
A
ABC
ABCDEFGH
%5S
####A
##ABC
ABCDEFGH
%.5S
A
ABC
ABCDE
%5.5S
####A
##ABC
ABCDE
%-5S
A####
ABC##
ABCDEFGH
Printf 格式化字符串
格式代码
1
-12
12345
123456789
%d
1
-12
12345
123456789
%6d
#####1
###-12
#12345
123456789
%.4d
0001
-0012
12345
123456789
%6.4d
##0001
#-0012
#12345
123456789
%-4d
1####
-12#
12345
123456789
%04d
0001
-012
12345
123456789
%+d
+1
-12
+12345
+123456789
Printf格式化整型数值
格式代码
1
.01
.00012345
12345.6789
%f
1.000000
0.010000
0.000123
12345.678900
%10.2d
######1.00
#####0.01
######0.00
##12345.67
%e
1.000000e+00
1.000000e-02
1.234500e-04
1.234568e+04
%.4e
1.0000e+00
1.0000e-02
1.2345e-04
1.2346e+04
%g
1
0.01
0.00012345
12345.7
格式代码
6.023e23
%f
60229999999999975882752.000000
%10.2e
60229999999999975882752.00
%e
6.023000e+23
%.4e
6.0230e+23
%g
6.023e+23
Printf格式化浮点值
本文地址:http://com.8s8s.com/it/it22511.htm