isnumeric (checking if string is numeric) Implementation? #11796
-
I am reading the output from a matrix keyboard library and am trying to check if the output (returned as a character from the library used) can be converted to a number. I saw that isalpha is implemented, but since the keypad can return "#" I am curious, is there is any equivalent to isnumeric implemented? And if not, is using a try except to get this behavior (as shown below) inadvisable? Thanks!
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
You can check multiple instances with isinstance()
|
Beta Was this translation helpful? Give feedback.
-
Thats one of many nice things: It becomes like if, else.--Diese Nachricht wurde von meinem Android Mobiltelefon mit GMX Mail gesendet.Am 16.06.23, 21:20 schrieb kat-rng ***@***.***>:
Thank you. I was a little worried that running trys and accepts constantly may cause problems, but I take it that it's fine.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
@kat-rng The try/except is appropriate. You have to consider that issue.
So you could also check if the characters of the string are in '+-.eE0123456789'. This excludes something like '1_000e3' but that should be no problem.