Parsing strings -> numbers
skip at pobox.com
Mon Nov 24 22:48:15 CET 2003
tuanglen> I've been looking all over in the docs, but I can't figure out
tuanglen> how you're *supposed* to parse formatted strings into numbers
tuanglen> (and other data types, for that matter) in Python.
Check out the locale module. From "pydoc locale":
Help on module locale:
locale - Locale support.
The module provides low-level access to the C lib's locale APIs
and adds high level number formatting APIs as well as a locale
aliasing engine to complement these.
atof(str, func=<type 'float'>)
Parses a string as a float according to the locale settings.
Converts a string to an integer according to the locale settings.
More information about the Python-list