You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

14 lines
448 B

# -*- coding: utf-8 -*-
import datetime
# convert datetime to json
dthandler = lambda obj: obj.isoformat() if isinstance(obj, datetime.datetime) or isinstance(obj, datetime.date) else None
def safe_int(value, default=None):
"""Возвращает value, приведенное к типу int, или default, если привести не получается."""
try:
return int(value)
except:
return default