Skip to content

Instantly share code, notes, and snippets.

@foowaa
Created December 6, 2018 08:20
Show Gist options
  • Save foowaa/5ef6340546de1bd9868c2350e25d2f0a to your computer and use it in GitHub Desktop.
Save foowaa/5ef6340546de1bd9868c2350e25d2f0a to your computer and use it in GitHub Desktop.
decide a string whether presents a number or not
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