{"id":392,"date":"2024-06-03T01:09:42","date_gmt":"2024-06-02T16:09:42","guid":{"rendered":"https:\/\/blog.gerd.kr\/?p=392"},"modified":"2024-06-03T01:09:42","modified_gmt":"2024-06-02T16:09:42","slug":"python-%ec%97%90%ec%84%9c-zipfile-%eb%aa%a8%eb%93%88%ec%9d%84-%ec%82%ac%ec%9a%a9%ed%95%a0-%eb%95%8c-%ea%b2%bd%eb%a1%9c-%eb%ac%b8%ec%a0%9c","status":"publish","type":"post","link":"https:\/\/blog.gerd.kr\/?p=392","title":{"rendered":"Python \uc5d0\uc11c zipfile \ubaa8\ub4c8\uc744 \uc0ac\uc6a9\ud560 \ub54c, \uacbd\ub85c \ubb38\uc81c"},"content":{"rendered":"\n<p>\uc694\uc998 ChatGPT \ub355\ubd84\uc5d0 \ud30c\uc774\uc36c \uc0ac\uc6a9\ud558\ub294\uac8c \ub108\ubb34 \uc7ac\ubbf8\uc788\ub2e4. \uadf8\ub0e5 \uc801\ub2f9\ud788 \ub300\ud654\ub9cc \ud558\uba74 \ubaa8\ub974\ub294 \uac78 \uc2f9 \uc54c\ub824\uc8fc\ub2c8\uae4c \ub108\ubb34 \ud3b8\ud558\uace0 \uc88b\ub2e4.<\/p>\n\n\n\n<p>\ucd5c\uadfc \uac1c\uc778\uc801\uc73c\ub85c \uc0ac\uc6a9\ud560 \uc720\ud2f8\ub9ac\ud2f0\ub97c \ub9cc\ub4e4\uba74\uc11c zipfile \ubaa8\ub4c8\uc744 \uc0ac\uc6a9\ud560 \uc77c\uc774 \uc788\uc5c8\ub294\ub370, \ucc98\uc74c ChatGPT \uac00 \uc54c\ub824\uc900 \ucf54\ub4dc\ub294 \uc774\ub7ac\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def CreateZIP(output_zip, *files):\n    with zipfile.ZipFile(output_zip, 'w') as zf:\n        for file in files:\n            zf.write(file, file)<\/code><\/pre>\n\n\n\n<p>\uc555\ucd95\uc740 \uc798 \ub418\uc5c8\ub294\ub370, \uc18c\uc2a4 \ud30c\uc77c\uc758 \uacbd\ub85c\uac00 \uadf8\ub300\ub85c \uc785\ub825\uc774 \ub418\uc5c8\ub2e4. \ub9cc\uc57d \uc555\ucd95\ud560 \ud30c\uc77c\uc758 \uc6d0\ub798 \uacbd\ub85c\uac00 C:\\Temp\\a.txt \ub77c\uba74, \uc555\ud479 \ud30c\uc77c\uc744 Download \ud3f4\ub354\uc5d0 \uc62e\uaca8\uc11c \ud480\uc5b4\ub3c4 &#8230;\\Download\\Temp\\a.txt \uac00 \ub418\ub294 \uc2dd\uc774\ub2e4. <\/p>\n\n\n\n<p>ChatGPT \uc5d0\uac8c \ub2e4\uc2dc \ubb3c\uc5b4\ubcf4\ub2c8\uae4c \uc218\uc815\ub41c \ucf54\ub4dc\ub97c \uc81c\uc2dc\ud574 \uc92c\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def CreateZIP(output_zip, *files):\n    with zipfile.ZipFile(output_zip, 'w') as zf:\n        for file in files:\n            zf.write(file, os.path.basename(file))<\/code><\/pre>\n\n\n\n<p>\ub4a4\uc5d0 \uacbd\ub85c\ub97c os \ubaa8\ub4c8\uc758 basename \ud568\uc218\ub97c \uc774\uc6a9\ud574\uc11c \ud30c\uc77c\uba85\ub9cc \ucd94\ucd9c\ud574\uc11c \uc9d1\uc5b4 \ub123\uc5c8\ub2e4. \uc774\ub807\uac8c \ud558\ub2c8\uae4c \uc798 \ub418\ub294\uac70 \uac19\uc558\ub294\ub370, \uba87\uba87 \ud30c\uc77c \ubdf0\uc5b4\uc640 \ub2e4\ub978 OS \uc758 \uce98\ub9ac\ubc84\uc5d0\uc11c \ubb38\uc81c\uac00 \uc0dd\uacbc\ub2e4. \uac04\ud5d0\uc801\uc73c\ub85c \uc81c\ub300\ub85c \uc77d\uc9c0 \ubabb\ud558\uac70\ub098 Cover \uc774\ubbf8\uc9c0\ub97c \uc0dd\uc131\ud558\uc9c0 \ubabb\ud558\uac70\ub098 \ud588\ub2e4.<\/p>\n\n\n\n<p>\uc774\ub798\uc800\ub798 \ubd84\uc11d\ud574 \ubcf4\ub2c8\uae4c, \uc0c1\ub300 \uacbd\ub85c\ub97c \uc81c\ub300\ub85c \ucc98\ub9ac\ud558\uc9c0 \ubabb\ud558\ub294 \uac83\uc774 \uc6d0\uc778\uc778 \uac83 \uac19\uc558\ub2e4. \uadf8\ub798\uc11c \uadf8\ub0e5 \uac15\uc81c\ub85c root \uacbd\ub85c\ub97c \uc0bd\uc785\ud574 \uc8fc\uc5c8\ub354\ub2c8 \uc798 \ub418\uc5c8\ub2e4!! \ucf54\ub4dc\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def CreateZIP(output_zip, *files):\n    with zipfile.ZipFile(output_zip, 'w') as zf:\n        for file in files:\n            pathTemp = os.path.join('root', os.path.basename(file) )\n            zf.write(file, pathTemp)<\/code><\/pre>\n\n\n\n<p>\uc0ac\uc2e4, \ub108\ubb34 \uc9dc\uce5c \ub0b4\uc6a9\uc774\ub77c \ud3ec\uc2a4\ud305\uae4c\uc9c4 \uc548 \ud558\ub824\uace0 \ud588\ub294\ub370, \uae4c\uba39\uc5b4\uc11c ChatGPT \ud55c\ud14c \ub2e4\uc2dc \ubb3c\uc5b4 \ubcf4\ub824\ub2e4\uac00, \uc774\uc804 \uc18c\uc2a4\ub97c \ucc3e\uc544\uc11c \uc5bc\ub978 \uba54\ubaa8 \uacb8 \ud3ec\uc2a4\ud305 \ud55c\ub2e4. \uc81c\ubc1c \uae4c\uba39\uc9c0 \uc880 \ub9d0\uc790. T^T<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc694\uc998 ChatGPT \ub355\ubd84\uc5d0 \ud30c\uc774\uc36c \uc0ac\uc6a9\ud558\ub294\uac8c \ub108\ubb34 \uc7ac\ubbf8\uc788\ub2e4. \uadf8\ub0e5 \uc801\ub2f9\ud788 \ub300\ud654\ub9cc \ud558\uba74 \ubaa8\ub974\ub294 \uac78 \uc2f9 \uc54c\ub824\uc8fc\ub2c8\uae4c \ub108\ubb34 \ud3b8\ud558\uace0 \uc88b\ub2e4. \ucd5c\uadfc \uac1c\uc778\uc801\uc73c\ub85c \uc0ac\uc6a9\ud560 \uc720\ud2f8\ub9ac\ud2f0\ub97c \ub9cc\ub4e4\uba74\uc11c zipfile \ubaa8\ub4c8\uc744 \uc0ac\uc6a9\ud560 \uc77c\uc774 \uc788\uc5c8\ub294\ub370, \ucc98\uc74c ChatGPT \uac00 \uc54c\ub824\uc900 \ucf54\ub4dc\ub294 \uc774\ub7ac\ub2e4. \uc555\ucd95\uc740 \uc798 \ub418\uc5c8\ub294\ub370, \uc18c\uc2a4 \ud30c\uc77c\uc758 \uacbd\ub85c\uac00 \uadf8\ub300\ub85c \uc785\ub825\uc774 \ub418\uc5c8\ub2e4. \ub9cc\uc57d \uc555\ucd95\ud560 \ud30c\uc77c\uc758 \uc6d0\ub798 \uacbd\ub85c\uac00 C:\\Temp\\a.txt \ub77c\uba74, \uc555\ud479 \ud30c\uc77c\uc744 Download \ud3f4\ub354\uc5d0 \uc62e\uaca8\uc11c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[34,112,113,114,115,111],"class_list":["post-392","post","type-post","status-publish","format-standard","hentry","category-howto","tag-python","tag-zip","tag-zipfile","tag-114","tag-115","tag-111"],"_links":{"self":[{"href":"https:\/\/blog.gerd.kr\/index.php?rest_route=\/wp\/v2\/posts\/392","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.gerd.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.gerd.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.gerd.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.gerd.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=392"}],"version-history":[{"count":1,"href":"https:\/\/blog.gerd.kr\/index.php?rest_route=\/wp\/v2\/posts\/392\/revisions"}],"predecessor-version":[{"id":393,"href":"https:\/\/blog.gerd.kr\/index.php?rest_route=\/wp\/v2\/posts\/392\/revisions\/393"}],"wp:attachment":[{"href":"https:\/\/blog.gerd.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=392"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.gerd.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=392"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.gerd.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=392"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}