Parsing strings -> numbers
Skip Montanaro
skip at pobox.com
Mon Nov 24 16:48:15 EST 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:
NAME
locale - Locale support.
FILE
/Users/skip/local/lib/python2.4/locale.py
MODULE DOCS
http://www.python.org/doc/current/lib/module-locale.html
DESCRIPTION
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.
...
FUNCTIONS
atof(str, func=<type 'float'>)
Parses a string as a float according to the locale settings.
atoi(str)
Converts a string to an integer according to the locale settings.
...
Skip
More information about the Python-list
mailing list