We have string.isdigit(), why not string.isNumber()?
Roy Smith
roy at panix.com
Wed Apr 30 21:03:45 EDT 2008
In article
<0d43feda-fab8-46ba-9af0-eaf497033acd at l17g2000pri.googlegroups.com>,
MooMaster <ntv1534 at gmail.com> wrote:
> So it makes sense that something like 5.6 would return false. But what
> if we want to make sure that our string is a valid number, ie decimals
> included?
Just call int(x) or float(x) inside a try block and see if if it raises an
exception.
More information about the Python-list
mailing list