What does 'h' mean in a python format string?
问题 This is a valid python format string: >>> wierd_format = '[%27he]' >>> print wierd_format % 2.5 [ 2.500000e+00] But this isn't: >>> bad_format = '[%20qe]' >>> print bad_format % 2.5 Traceback (most recent call last): File "prog.py", line 5, in <module> print bad_format % 2.5 ValueError: unsupported format character 'q' (0x71) at index 4 Clearly, h is a supported format character. However, the documentation doesn't mention an h specifier. What does it do? 回答1: From the docs: A length modifier