国产成人AV无码一二三区,少女1到100集,国产精品久久久久精品综合紧,巜公妇之诱感肉欲HD在线播放

文章 > Python基础教程 > python如何生成tar文件内容

python如何生成tar文件内容

Python tar 文件

头像

爱喝马黛茶的安东尼

2019-09-23 17:20:166520浏览 · 0收藏 · 0评论

tarfile包中的.open(name, mode)方法能够以mode指定的方式打开name压缩文件,并返回一个TarFile类对象。调用TarFile对象的extractall(path)方法可以将tar文档解压到path指定的位置。

import tarfile
tar = tarfile.open( '*.tar.gz', mode = "r:gz") #"r:gz"表示 open for reading with gzip compression
tar.extractall(path='temp')  ### 将tar.gz文件解压到temp文件夹下
tar.close()

open返回的对象不但可以用来读文档数据('r': reading),还可以写('w': writing),附加('a': appending)。

相关推荐:《Python教程

如下是mode取值所对应的含义:

'r' or 'r:*' open for reading with transparent compression
'r:'         open for reading exclusively uncompressed
'r:gz'       open for reading with gzip compression
'r:bz2'      open for reading with bzip2 compression
'r:xz'       open for reading with lzma compression
'a' or 'a:'  open for appending, creating the file if necessary
'w' or 'w:'  open for writing without compression
'w:gz'       open for writing with gzip compression
'w:bz2'      open for writing with bzip2 compression
'w:xz'       open for writing with lzma compression
 
'x' or 'x:'  create a tarfile exclusively without compression, raise
             an exception if the file is already created
'x:gz'       create a gzip compressed tarfile, raise an exception
             if the file is already created
'x:bz2'      create a bzip2 compressed tarfile, raise an exception
             if the file is already created
'x:xz'       create an lzma compressed tarfile, raise an exception
             if the file is already created
 
'r|*'        open a stream of tar blocks with transparent compression
'r|'         open an uncompressed stream of tar blocks for reading
'r|gz'       open a gzip compressed stream of tar blocks
'r|bz2'      open a bzip2 compressed stream of tar blocks
'r|xz'       open an lzma compressed stream of tar blocks
'w|'         open an uncompressed stream for writing
'w|gz'       open a gzip compressed stream for writing
'w|bz2'      open a bzip2 compressed stream for writing
'w|xz'       open an lzma compressed stream for writing
关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

UFOTABLE| 苍井空| YY漫画首页登录入口页面在哪里| NYLONJP| BOBO浏览器| 美足网| 巨茎挺进李淑芬的体内视频| 光溜溜女孩视频大全| 《军妓肉体》在线观看| 欢愉骑行1-27章内容概括 | 姐姐呀姐姐快停下是什么歌曲| 《性呻吟》伦理| 他扒开我小沉添我三男一女视频 | 《完美邻居2》电影在线观看| 白日梦我电视剧免费观看完整版 | 刚长毛的初一女生年龄范围| 精品一区二区三区| 武松叼着潘金莲奶头的是谁扮演的| 男按摩师舌头伸进去了SPA漫画| 公厕少年NASA动漫免费观看| 范文先生网| 公交车被上高湖了还能坐吗小说 | YSL口红水蜜桃色号1258| 老头握住淑蓉双乳| WWW.1688.GOVCN| 黄瓜视频APP| 《厨房激战5》完整版在线观看| 妈妈让我戴上避孕套的下一句是啥| 开档情趣内衣| 曾鲁射击免费播放电视剧全部 | 免费观看B站刺激战场2023| 《办公室高潮秘书2》| 男生把小困困放到女生困里视频| 翁吻乳婷婷小玲21章| 女生给男生吃小头头| 火车上荫蒂添的好舒服电影| 男人女人和孩子| 老公拿狗给我配| 《我的漂亮老板娘》演员名单| 《初尝禁果》2:做爰电影 | 乳头夹夹太紧好疼怎么缓解