data_Utils.py 文件源码

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

项目:warriorframework 作者: warriorframework 项目源码 文件源码
def convert2type(value, data_type='str'):
    """Convert value to data_type and return value in that data_type
    Currently supported are str/int/float only
    """
    type_funcs = {'str': str, 'int': int, 'float': float}
    convert = type_funcs[data_type]
    cvalue = value
    try:
        cvalue = convert(value)
    except ValueError:
        print_error("'{}' should be of type {}, please correct".format(value, data_type))
    except Exception as exception:
        print_exception(exception)
    return cvalue
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号