Re: Best way to check if string is an integer?
- From: Mark Dickinson <dickinsm@xxxxxxxxx>
- Date: Sat, 5 Apr 2008 16:25:49 -0700 (PDT)
On Apr 5, 6:19 pm, skanem...@xxxxxxxx wrote:
which is the best way to check if a string is an number or a char?
could the 2nd example be very expensive timewise if i have to check a
lot of strings?
You might be interested in str.isdigit:
S.isdigit() -> boolprint str.isdigit.__doc__
Return True if all characters in S are digits
and there is at least one character in S, False otherwise.
Mark
.
- Follow-Ups:
- Re: Best way to check if string is an integer?
- From: John Machin
- Re: Best way to check if string is an integer?
- References:
- Best way to check if string is an integer?
- From: skanemupp
- Best way to check if string is an integer?
- Prev by Date: Re: Best way to check if string is an integer?
- Next by Date: while-loops enter the last time after condition is filled?
- Previous by thread: Re: Best way to check if string is an integer?
- Next by thread: Re: Best way to check if string is an integer?
- Index(es):
Relevant Pages
|