utilities
This module contains utility functions for parsing various strings.
Functions
- parse_datetime(string: str, default_timezone: tzinfo) datetime[source]
Parse a timestamp string. If the timestamp does not specify a timezone, default_timezone is used.
- Parameters:
string (str) – The string to parse.
default_timezone (datetime.tzinfo) – The default timezone to set.
- Return type:
- parse_float(string: str, *, int_max_digits: int | None = None) Decimal[source]
Parse a literal string representing a floating point value.
Changed in version 5.1.1: Added the int_max_digits parameter.
- Parameters:
string (str) – The string to parse.
int_max_digits (int) – The maximum number of digits that a binary, octal or hexadecimal literal can have once converted to a decimal value. See
coerce_value()for details.
- Return type:
- Raises:
ArithmeticError – string is a binary, octal or hexadecimal literal with more digits than allowed by int_max_digits.