Michael Amrhein <mich...@adrhinum.de> added the comment:
> > ... Has anyone checked what C does? > #include <stdio.h> int main() { int i = -12345; double f = -12345.0; printf("%-020d\n", i); printf("%020d\n", i); printf("%20d\n", i); printf("%-020f\n", f); printf("%020f\n", f); printf("%20f\n", f); return 0; } Output: -12345 -0000000000000012345 -12345 -12345.000000 -000000012345.000000 -12345.000000 https://en.cppreference.com/w/c/io/fprintf: Each conversion specification has the following format: introductory % character (optional) one or more flags that modify the behavior of the conversion: -: the result of the conversion is left-justified within the field (by default it is right-justified) +: the sign of signed conversions is always prepended to the result of the conversion (by default the result is preceded by minus only when it is negative) space: if the result of a signed conversion does not start with a sign character, or is empty, space is prepended to the result. It is ignored if + flag is present. # : alternative form of the conversion is performed. See the table below for exact effects otherwise the behavior is undefined. 0 : for integer and floating point number conversions, leading zeros are used to pad the field instead of space characters. For integer numbers it is ignored if the precision is explicitly specified. For other conversions using this flag results in undefined behavior. It is ignored if - flag is present. Last sentence means that zero-padding is only done when the output is right-aligned. I can't find an equivalent for Pythons '=' align option. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39077> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com