
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
q2numfmt is a lightweight Python package for formatting numeric data using Excel-style number format strings. It follows the ECMA-376 - Office Open XML file formats - 5th edition, December 2021 specification—the same standard used by Microsoft Excel to format numbers.
Decimal
values."0.00"
, "0%"
, "$#,##0.00"
).numFmts
).pip install q2numfmt
from q2numfmt import format_number
print(format_number(1234.567, "#,##0.00")) # "1,234.57"
print(format_number("0.056", "0.0%")) # "5.6%"
print(format_number(-1234.5, "$#,##0.00")) # "-$1,234.50"
print(format_number(0, '[Green]0.00;[Red]-0.00')) # "0.00"
format_number(value, format_string)
Formats a number using an Excel-style number format string.
value: int, float, str, or decimal.Decimal
format_string: A string format as defined in Excel / ECMA-376
Returns a str with the formatted result.
Format String | Input | Output |
---|---|---|
0.00 | 12.3 | 12.30 |
#,##0 | 12345 | 12,345 |
0.0% | 0.1234 | 12.3% |
$#,##0.00 | -1234.5 | -$1,234.50 |
1234.59 | ####.# | 1234.6 |
[Red]-0.0 | -5.5 | -5.5 |
The package is based on:
ECMA-376-1:2016, Part 1 – Office Open XML File Formats
Section 18.8.31: numFmts (Custom Number Formats in Excel)
This project is licensed under the MIT License – see the LICENSE file for details.
PyPI: https://pypi.org/project/q2numfmt
GitHub: https://github.com/AndreiPuchko/q2numfmt
Andrei Puchko GitHub: https://github.com/AndreiPuchko
Contributions, issues, and feature requests are welcome! Feel free to check the issues page or submit a pull request.
FAQs
Excel-style number formatting for Python.
We found that q2numfmt demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.