it's digit (includes negative digits as well)?
The isdigit function checks only positive digits.
regex
I think using int() should be enough, use try to catch ValueError
Use can apply the abs function and then use isdigit()
Don't know if regex would be the most efficient though. If you need performance I would also try checking if the first character is a minus, and then using isdigit on the rest of the string. I'd test whether this is slower or faster than using regex
Have u tried 'isnumeric()' ?
Обсуждают сегодня