util.py 文件源码

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

项目:deb-python-pint 作者: openstack 项目源码 文件源码
def string_preprocessor(input_string):

    input_string = input_string.replace(",", "")
    input_string = input_string.replace(" per ", "/")

    for a, b in _subs_re:
        input_string = a.sub(b, input_string)

    # Replace pretty format characters
    for pretty_exp in _pretty_exp_re.findall(input_string):
        exp = '**' + pretty_exp.translate(_pretty_table)
        input_string = input_string.replace(pretty_exp, exp)
    input_string = input_string.translate(_pretty_table)

    # Handle caret exponentiation
    input_string = input_string.replace("^", "**")
    return input_string
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号