• python中的zipfile


    zipfile — Work with ZIP archives

    ZipFile.namelist()
    Return a list of archive members by name.
    返回压缩成员名称列表

    with ZipFile('spam.zip', 'r') as myzip:
        for f in myzip.namelist():
            print(f)


    ZipFile.getinfo(name)
    Return a ZipInfo object with information about the archive member name. Calling getinfo() for a name not currently contained in the archive will raise a KeyError.
    根据成员名称获取ZipInfo

    ZipFile.infolist()
    Return a list containing a ZipInfo object for each member of the archive. The objects are in the same order as their entries in the actual ZIP file on disk if an existing archive was opened.
    返回ZipInfo列表

    ZipFile.extract(member, path=None, pwd=None)
    ZipFile.extractall(path=None, members=None, pwd=None)
    解压缩文件,path指定路径(默认为当前路径)

    ZipFile.write(filename, arcname=None, compress_type=None)
    ZipFile.writestr(zinfo_or_arcname, bytes[, compress_type])
    写入, arcname压缩后成员名称
    with ZipFile('spam.zip', 'w') as myzip:
        myzip.write('eggs.txt')


  • 相关阅读:
    Bash's Big Day
    树链剖分求lca
    Contest1814
    启发式合并
    2019 Multi-University Training Contest 10
    图论题
    vijos-记数问题
    2018届研究生招生预推免(THU,HIT)经历分享
    数细胞-swust oj
    Bone Collector-HDU
  • 原文地址:https://www.cnblogs.com/xkxjy/p/3672256.html
Copyright © 2020-2023  润新知