Can I specify regex group to return float or int instead of string?
steve at REMOVE-THIS-cybersource.com.au
Thu Feb 25 17:41:01 CET 2010
On Thu, 25 Feb 2010 07:48:44 -0800, Jeremy wrote:
> I have a regular expression that searches for some numbers and puts them
> into a dictionary, i.e.
> Is it possible to have the results of the matches returned as int or
> float objects instead of strings?
No. Just convert the match with int() or float() before storing it in the
dictionary. That is, instead of:
d[key] = match
d[key] = float(match)
More information about the Python-list