libb.round_digit_string

round_digit_string(s, places=None)[source]

Round a numeric string to specified decimal places.

Parameters:
  • s (str) – Numeric string to round.

  • places (int) – Number of decimal places (None to preserve original).

Returns:

Rounded numeric string.

Return type:

str

Example:

>>> round_digit_string('7283.1234', 3)
'7283.123'
>>> round_digit_string('7283.1234', None)
'7283.1234'
>>> round_digit_string('7283', 3)
'7283'