跳到主要內容區塊
Dhlen.zip » 〈PREMIUM〉
import zipfile with zipfile.ZipFile('dhlen.zip', 'r') as z: with z.open('filename.txt') as f: print(f.read().decode('utf-8')) Use code with caution. Copied to clipboard
If you are trying to produce text programmatically without manually unzipping: Use the zipfile module to read content directly: dhlen.zip
If there is already a .txt file inside the archive, you can extract it: import zipfile with zipfile
You can use the "Print" menu and select a "Generic/Text" printer to save the file list as a .txt file . import zipfile with zipfile.ZipFile('dhlen.zip'
If you want to create a text document that lists everything inside the .zip :
Use the command unzip dhlen.zip "filename.txt" to extract a specific file. 2. Generating a List of Files as Text