libb.commafy
- commafy(n)[source]
Add commas to a numeric value.
- Parameters:
n – Number or string to add commas to.
- Returns:
String with comma separators.
- Return type:
str or None
Example:
>>> commafy(1) '1' >>> commafy(123) '123' >>> commafy(-123) '-123' >>> commafy(1234) '1,234' >>> commafy(1234567890) '1,234,567,890' >>> commafy(123.0) '123.0' >>> commafy(1234.5) '1,234.5' >>> commafy(1234.56789) '1,234.56789' >>> commafy(f'{-1234.5:.2f}') '-1,234.50' >>> commafy(None) >>>