NDOJ/judge/utils/strings.py
2020-01-21 15:35:58 +09:00

12 lines
246 B
Python

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