'e'
Floating point exponential format (lowercase).
(3)
'E'
Floating point exponential format (uppercase).
(3)
'f'
Floating point decimal format.
(3)
'F'
Floating point decimal format.
(3)
'g'
Floating point format. Uses lowercase exponential format if exponent is less than -4 or not less than precision, decimal format otherwise.
(4)
'G'
Floating point format. Uses uppercase exponential format if exponent is less than -4 or not less than precision, decimal format otherwise.
(4)
'c'
Single character (accepts integer or single character string).
'r'
String (converts any Python object using repr()).
(5)
's'
String (converts any Python object using str()).
(5)
'a'
String (converts any Python object using ascii()).
(5)
'%' 输出%
Notes:
The alternate form causes a leading zero ('0') to be inserted between left-hand padding and the formatting of the number if the leading character of the result is not already a zero.当使用了转换标志0,那么填充0的时候,填充的位置将是0o和数字之间,比如%#08o' % 34的结果是0o000042
The alternate form causes a leading '0x' or '0X' (depending on whether the 'x' or 'X' format was used) to be inserted between left-hand padding and the formatting of the number if the leading character of the result is not already a zero.当使用了转换标志0,那么填充0的时候,填充的位置将是0x和数字之间,比如%#08x' % 34的结果是0x000022。
The alternate form causes the result to always contain a decimal point, even if no digits follow it.
The precision determines the number of digits after the decimal point and defaults to 6.精度控制决定了小数点后的位数,默认是6位
The alternate form causes the result to always contain a decimal point, and trailing zeroes are not removed as they would otherwise be.
The precision determines the number of significant digits before and after the decimal point and defaults to 6.
If precision is N, the output is truncated to N characters.如果上面指定的精度是N,那么字符串的最大长度是N
See PEP 237.
Since Python strings have an explicit length, %s conversions do not assume that '\0' is the end of the string.
因为Python的String有显式的长度,所以%s转换不认为'\0'是字符串的结尾
Changed in version 3.1: %f conversions for numbers whose absolute value is over 1e50 are no longer replaced by %g conversions.