extract-dtb.py 文件源码

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

项目:extract-dtb 作者: PabloCastellano 项目源码 文件源码
def get_dtb_model(filename, min_length=4):
    """ Finds the first printable string in a file with length greater
        than min_length. Replaces spaces with underscores.
    """
    with open(filename, errors="ignore") as f:
        result = ""
        for c in f.read():
            if c in string.printable:
                result += c
                continue
            if len(result) >= min_length:
                return result.replace(" ", "_")
            result = ""
        if len(result) >= min_length:  # catch result at EOF
            return result.replace(" ", "_")
    return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号