国产成人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
关注

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

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

无人区免费观看高清电视剧| 三更2饺子截取一小段| 《伦敦空姐美版2023》| 老师穿白色双开真丝旗袍怎么穿| 公交车被上高湖了还能坐吗小说 | 特级牲交大片20分钟-春梦AV| 在线观看日本韩国电影电视剧| 无人区免费高清版观看| 我把校花嘴巴当套子的小说| 艾梅柏·希尔德| 《魅魔之耻》1~4集免费看| 日韩成人无码| 少女たちよ观看免费高清电视剧| 两只奶头被老头吸肿了| 蜜桃成熟时1997》主题曲歌..| 成品网站免费直播有哪些平台推荐| 丈夫不在的日子中字头| 漂亮的女邻居5》HD| 美女和帅哥一起努力生产豆浆的视. | 白色变态蕾丝超薄开档连身袜| BOBO浏览器老司机模式改版特.| Y8848影院电视剧免费| 女兒亂倫在线观看| 《父承子液》金银花原文主角| 榜上佳婿电视剧全集免费观看高清| 欧美-区| 《不再是朋友的夜晚第二季》| 法国《口咬》电影完整版| 器材室轮-J-(1):蒙着眼在...| 九九在线观看免费播放大全电视剧| 国产精品免费人成网站酒店店| 黑料网| 鲁鲁影院免费观看电视剧电影| 今天的高清视频在线观看高清 | お母さんは母のがいない怎么读| 50岁阿姨大人免费观看电视剧| 中文字幕在线观看| 男女啪啪做爰高潮全过有多动症| 密爱电影版完整版免费观看高清| 邻家阿姨完整版免费观看| 妈妈的好朋友ID