简体   繁体   English

在Python中使用tarfile.open()时打开文件的顺序

[英]Order of opening files when using tarfile.open() in Python

I have a simple question yet I didn't manage to find a lot of information about it or understand it very well. 我有一个简单的问题,但我没有找到很多有关它的信息或非常了解它。

When I open a tarfile in python using the tarfile.open() method, how exactly are the files in the tarfile read? 当我使用tarfile.open()方法在python中打开tarfile时,如何准确读取tarfile中的文件? I have a tarfile with data on people, each person has his own folder and in that folder his data is divided between different folders. 我有一个包含人员数据的tarfile,每个人都有自己的文件夹,在该文件夹中,他的数据分配在不同的文件夹中。

Will the files be accessed depending on internal structure or is there another way to determine which file will be accessed next when I use tarfile.extractfile() ? 使用tarfile.extractfile()时是否会根据内部结构来访问文件,还是有另一种方法来确定接下来将访问哪个文件?

Thank you in advance 先感谢您

Internal structure. 内部结构。 tar stands for "tape archive", and the big design point is the ability to work sequentially with small RAM, while writing to (or reading from) a sequential-access IO device (also known as tape): loading everything into memory and then processing it in some specific order was not possible. tar代表“磁带存档”,最大的设计要点是能够与小型RAM顺序工作,同时写入(或读取)顺序访问IO设备(也称为磁带):将所有内容加载到内存中,然后无法按特定顺序处理它。 Thus, files are extracted in the order they are found in the archive, by reading the archive in order. 因此,通过按顺序读取档案,将按在档案中找到文件的顺序提取文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM