Notice: file_put_contents(): Write of 17577 bytes failed with errno=28 No space left on device in /var/www/tgoop/post.php on line 50
[PYTHON:TODAY]@python2day P.6773
PYTHON2DAY Telegram 6773
📦 Архивация в Python всего за несколько строк

Никаких сторонних библиотек — всё делает встроенный модуль zipfile

import zipfile

def make_zip(target_files: list[str], zip_name: str = 'data.zip') -> None:
"""Упаковывает файлы в ZIP-архив с указанным именем."""
with zipfile.ZipFile(zip_name, 'w') as archive:
for filename in target_files:
archive.write(filename) # Добавляем файл в архив
print(f" Архив {zip_name} создан!")

make_zip(['image.png', 'notes.md'])


👨‍💻 Удобно для логов, бэкапов или автосборки. Хороший вариант для скриптов, где надо временно упаковать кучу файлов.

📂 Сохраняй, пригодится!

#python #code
Please open Telegram to view this post
VIEW IN TELEGRAM
👍48🔥103



tgoop.com/python2day/6773
Create:
Last Update:

📦 Архивация в Python всего за несколько строк

Никаких сторонних библиотек — всё делает встроенный модуль zipfile

import zipfile

def make_zip(target_files: list[str], zip_name: str = 'data.zip') -> None:
"""Упаковывает файлы в ZIP-архив с указанным именем."""
with zipfile.ZipFile(zip_name, 'w') as archive:
for filename in target_files:
archive.write(filename) # Добавляем файл в архив
print(f" Архив {zip_name} создан!")

make_zip(['image.png', 'notes.md'])


👨‍💻 Удобно для логов, бэкапов или автосборки. Хороший вариант для скриптов, где надо временно упаковать кучу файлов.

📂 Сохраняй, пригодится!

#python #code

BY [PYTHON:TODAY]




Share with your friend now:
tgoop.com/python2day/6773

View MORE
Open in Telegram


Telegram News

Date: |

Invite up to 200 users from your contacts to join your channel Write your hashtags in the language of your target audience. Telegram is a leading cloud-based instant messages platform. It became popular in recent years for its privacy, speed, voice and video quality, and other unmatched features over its main competitor Whatsapp. Among the requests, the Brazilian electoral Court wanted to know if they could obtain data on the origins of malicious content posted on the platform. According to the TSE, this would enable the authorities to track false content and identify the user responsible for publishing it in the first place. Telegram Android app: Open the chats list, click the menu icon and select “New Channel.”
from us


Telegram [PYTHON:TODAY]
FROM American