jsonme.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:cobrame 作者: SBRG 项目源码 文件源码
def _fix_type(value):
    """convert possible types to str, float, and bool"""
    # Because numpy floats can not be pickled to json
    if isinstance(value, string_types):
        return str(value)
    if isinstance(value, float_):
        return float(value)
    if isinstance(value, bool_):
        return bool(value)
    if isinstance(value, set):
        return list(value)
    if isinstance(value, Basic):
        return str(value)
    if hasattr(value, 'id'):
        return str(value.id)
    # if value is None:
    #     return ''
    return value
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号