背景我的主目錄中有一些名為delivery_content. 該目錄內有兩個文件夾content_123和content_456。每個目錄都包含一個文本文件。所以整體結構如下所示。-delivery_content -content_123/ -content_123.txt -content_456/ -content_456.txt我正在編寫代碼,當給定一個目錄時,它將壓縮它的所有內容。代碼import osimport shutilfrom pathlib import Pathfrom datetime import datetimeDOWNLOAD_DIR = Path(os.getenv("HOME")) / "delivery_content"date = datetime.today().strftime("%Y-%m-%d")delivery_name = f"foo_{date}"shutil.make_archive(str(DOWNLOAD_DIR / delivery_name), "zip", str(DOWNLOAD_DIR))print("Zipping Has Complete")因此,對于上面給定的代碼,我希望在 中看到 foo_todays_date.zip,DOWNLOAD_DIR當我解壓縮它時,我希望看到以下內容 -content_123/ -content_123.txt -content_456/ -content_456.txt但是我看到以下內容有什么方法可以避免我的 zip 文件中包含 .zip 嗎?
ZipFile 內的 ZipFile (Python)
12345678_0001
2024-01-24 15:45:16