![]() The first is to get the file names of all files in the download folder import globįilename_lst = The decompression codes of different compressed files are different, and will be expanded in the subsequent code operations.Ĭode words are not easy to talk nonsense: if you need python learning materials or have technical problems, just " click " to communicate 3. If the file ends with gz, after decompression, you need to judge whether it ends with. Therefore, the logic for judging whether a file is a compressed file can be as follows:Ĭreate a list with compressed package suffix compressed_lst = Īll file names under the target folder run filename.split(.) to get the suffixĭetermine whether the suffix name is in compressed_lst, if it exists, run the subsequent decompression code rar: Packed compressed files, originally used for DOS tar.gz but can pack and compress multiple files tar: Essentially not a compression tool but a packaging tool, it can be combined with. gz: That is gzip, usually only one file can be compressed When it comes to compressed files, it is necessary to discuss different compression formats, mainly in the following four types. When it comes to compressed files, it is necessary to discuss different compression formats, mainly in the following four types: If there is a new compressed file, extract it to a new folder in the current folder and delete the compressed file ![]() Regularly detect whether there is a compressed file in a folder (such as the download folder) Step analysis and pre-knowledgeīefore coding the code, it is necessary to interpret complex problems into multiple clear requirements, that is, the logic implemented by this program is: Knowledge points that can be learned through this case: os module comprehensive applicationĭecompress files using the gzip zipfile rarfile tarfile module 2. Write a Python program that automatically decompresses the internal files to the current folder and deletes the compressed package after each download of a file in the form of a compressed package.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |