NDOJ/judge/utils/strings.py

13 lines
246 B
Python
Raw Normal View History

2020-01-21 06:35:58 +00:00
def safe_int_or_none(value):
try:
return int(value)
except (ValueError, TypeError):
return None
def safe_float_or_none(value):
try:
return float(value)
except (ValueError, TypeError):
return None