datetime.datetime(2014, 1, 23, 21, 6, 37) is not JSON serializable

class MyEncoder(json.JSONEncoder):


    def default(self, obj):

        if isinstance(obj, datetime.datetime):

            return obj.strftime('%Y-%m-%d %H:%M:%S')

        elif isinstance(obj, datetime.date):

            return obj.strftime('%Y-%m-%d')

        elif isinstance(obj, decimal.Decimal):

            return float(obj)

        return json.JSONEncoder.default(self, obj)



info=json.dumps([dict(zip(cols, row)) for row in rows],cls = MyEncoder)


你可能感兴趣的:(datetime.datetime(2014, 1, 23, 21, 6, 37) is not JSON serializable)