Python Forum
zip file variable prints <zipfile.ZipFile object at 0x7f83fd13bd90> ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
zip file variable prints <zipfile.ZipFile object at 0x7f83fd13bd90> ?
#2
The zipfile itself should be outside of "server1".
To zip the directory "server1", you have to loop over the files.

!/usr/bin/python3
import os, zipfile

server1 = "test"
log_file_name = "logfile"

zip_file = zipfile.ZipFile(log_file_name + ".zip", "w")
for dirname, subdirs, files in os.walk(server1):
    for filename in files:
        zip_file.write(os.path.join(dirname, filename))
zip_file.close()
Reply


Messages In This Thread
RE: zip file issue - by heiner55 - Jun-25-2019, 05:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Using zipfile module - finding folders not files darter1010 2 295 Apr-06-2024, 07:22 AM
Last Post: Pedroski55
  zipfile module error pseudo 3 809 Jun-30-2023, 03:52 PM
Last Post: Gribouillis
  zfill prints extra et the end of a var tester_V 4 922 Mar-24-2023, 06:59 PM
Last Post: tester_V
  [Solved by deanhystad] Create a zip file using zipfile library DZ_Galaxy 2 1,194 Aug-17-2022, 04:57 PM
Last Post: DZ_Galaxy
  Can ZipFile be used to extract hidden files? AiedailEclipsed 0 1,653 Mar-22-2022, 05:21 PM
Last Post: AiedailEclipsed
  variable prints without being declared. ClockPillow 2 1,827 Jul-11-2021, 12:13 AM
Last Post: ClockPillow
  Created zipfile without all the subfolder? korenron 3 3,816 Jun-23-2021, 12:44 PM
Last Post: korenron
  Create ZIP file not working using ZipFile? korenron 1 2,136 Jun-13-2021, 04:15 PM
Last Post: korenron
  Output prints Account.id at the end? LastStopDEVS 5 2,822 Dec-19-2020, 05:59 AM
Last Post: buran
  Defining an object's argument whose name is stored in a variable arbiel 2 2,207 Dec-11-2020, 10:19 PM
Last Post: arbiel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020