utilities.py 文件源码

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

项目:pandachaika 作者: pandabuilder 项目源码 文件源码
def get_zip_filesize(filepath: str) -> int:
    try:
        my_zip = zipfile.ZipFile(filepath, 'r')
    except zipfile.BadZipFile:
        return -1

    info_list = my_zip.infolist()
    total_size = 0

    for info in info_list:
        if not info.filename.lower().endswith(
            ('.jpeg', '.jpg', '.png', '.gif')
        ):
            continue
        if '__macosx' in info.filename.lower():
            continue
        total_size += int(info.file_size)

    my_zip.close()

    return total_size
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号