parsing.py 文件源码

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

项目:fabric8-analytics-common 作者: fabric8-analytics 项目源码 文件源码
def parse_float_value_from_text_stream(text, key):
    """Parse float value from the text.

    Go through all lines of the text file, find the line with given key
    and parse float value specified here.
    """
    regexp = key + "\s*=\s*(\d.\d*)"
    for line in text.split("\n"):
        if line.startswith(key):
            # the key was found, now try to find and parse the float value
            match = re.fullmatch(regexp, line)
            assert match is not None
            assert match.lastindex == 1
            return float(match.group(1))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号