'Formatting negative numbers with math minus (U+2212) instead of hyphen-minus (U+002D)
I want to format negative numbers as strings where the minus sign has the same font width of plus sign. With
>>> '{}'.format(-2)
'-2'
the minus sign you get in the resulting string is the character u'\u002d' (I use this website to check character codes), which in many fonts is much narrower and even lower than plus sign.
Instead I would like the minus sign to be represented by the character u'\u2212', which is the mathematical minus sign and has the same width and vertical alignment of plus sign in all fonts (at least the ones I checked and I'll ever need).
Is there a way to change the behavior of a Python environment so that, when formatting negative numbers, math minus sign (U+2212) is used instead of hyphen-minus (U+002D)?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
