Created
December 6, 2018 08:20
-
-
Save foowaa/5ef6340546de1bd9868c2350e25d2f0a to your computer and use it in GitHub Desktop.
decide a string whether presents a number or not
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_number(s): | |
try: | |
float(s) | |
return True | |
except ValueError: | |
pass | |
try: | |
import unicodedata | |
unicodedata.numeric(s) | |
return True | |
except (TypeError, ValueError): | |
pass | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment