啊啊啊

importUnRAR

# extract all the files in test.rar
UnRAR.Archive('test.rar').extract()

# extract all the files in test.rar matching the wildcard *.txt
UnRAR.Archive('test.rar').extract('*.txt')

# print the name and size of each file, extracting small ones
forfileInArchiveinUnRAR.Archive('test.rar').iterfiles():
    printfileInArchive.filename,fileInArchive.size
    iffileInArchive.size<=1024:
        fileInArchive.extract()

# print the contents of any file whose name ends with test.txt
forfileInArchiveinUnRAR.Archive('test.rar').iterfiles():
    iffileInArchive.filename.endswith('test.txt'):
       printfileInArchive.open('rt').read()
posted @ 2012-08-03 02:19  dengyigod  阅读(188)  评论(0编辑  收藏  举报