【python】解压文件
生活随笔
收集整理的這篇文章主要介紹了
【python】解压文件
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
參考:http://essen.iteye.com/blog/1941489
?
tarfile模塊
具體使用方法:?https://docs.python.org/2/library/tarfile.html
?
例子:一次性解壓所有文件
import tarfilet = tarfile.open("abc.tgz", "r:gz")t.extractall(path = 'dir/')t.close()
?
還可以一次解壓一個文件
tar = tarfile.open(filename, 'r:gz') for tar_info in tar:file = tar.extractfile(tar_info)do_something_with(file)
?
轉載于:https://www.cnblogs.com/dplearning/p/5860294.html
總結
以上是生活随笔為你收集整理的【python】解压文件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 求一个属鸡好听的男孩名字。
- 下一篇: 去医院看妇科要多少钱?