{"id":2236,"date":"2026-11-09T13:00:00","date_gmt":"2026-11-09T04:00:00","guid":{"rendered":"https:\/\/danlabs.kr\/?p=2236"},"modified":"2026-11-14T01:37:44","modified_gmt":"2026-11-13T16:37:44","slug":"python-shutil-%ed%8c%8c%ec%9d%bc-%eb%b3%b5%ec%82%ac-copy%c2%b7copy2%ec%99%80-%eb%a9%94%ed%83%80%eb%8d%b0%ec%9d%b4%ed%84%b0-%eb%b3%b4%ec%a1%b4-%eb%b2%94%ec%9c%84","status":"publish","type":"post","link":"https:\/\/danlabs.kr\/?p=2236","title":{"rendered":"Python shutil \ud30c\uc77c \ubcf5\uc0ac \u2014 copyfile\u00b7copy\u00b7copy2\uc758 \uba54\ud0c0\ub370\uc774\ud130 \ubcf4\uc874 \ucc28\uc774"},"content":{"rendered":"<p>Python\uc758 shutil\uc740 \ud30c\uc77c \ubcf5\uc0ac \ud568\uc218\ub97c \uc81c\uacf5\ud574\uc694. \ubcf5\uc0ac\ud55c \ud30c\uc77c\uc758 \ub0b4\uc6a9\uc774 \uac19\ub354\ub77c\ub3c4 \uad8c\ud55c\uc774\ub098 \uc2dc\uac04 \uc815\ubcf4\uc758 \ubcf4\uc874 \uc5ec\ubd80\ub294 \uc120\ud0dd\ud55c \ud568\uc218\uc5d0 \ub530\ub77c \ub2ec\ub77c\uc838\uc694.[1] copyfile\u00b7copy\u00b7copy2\uac00 \uac01\uac01 \ubb34\uc5c7\uc744 \ubcf5\uc0ac\ud558\ub294\uc9c0 \uad6c\ubd84\ud558\uba74 \ud544\uc694\ud55c \ubcf4\uc874 \ubc94\uc704\uc5d0 \ub9de\ucdb0 \ud568\uc218\ub97c \uc120\ud0dd\ud560 \uc218 \uc788\uc5b4\uc694.<\/p>\n<figure><img decoding=\"async\" src=\"https:\/\/danlabs.kr\/wp-content\/uploads\/2026\/11\/dev-20261109-inline1.jpg\" alt=\"\ub0b4\uc6a9\uacfc \uad8c\ud55c \ubc0f \uba54\ud0c0\ub370\uc774\ud130\uc5d0 \ub530\ub978 \ud30c\uc77c \ubcf5\uc0ac \uc120\ud0dd\" \/><\/figure>\n<h2>copyfile: \ub300\uc0c1 \ud30c\uc77c \uc774\ub984\uc744 \uc9c0\uc815\ud574 \ub0b4\uc6a9\ub9cc \ubcf5\uc0ac\ud558\uae30<\/h2>\n<p><code>shutil.copyfile(src, dst)<\/code>\ub294 \uc6d0\ubcf8 \ud30c\uc77c\uc758 \ub0b4\uc6a9\uc744 \ub300\uc0c1 \ud30c\uc77c\uc5d0 \ubcf5\uc0ac\ud558\uace0 \ub300\uc0c1 \uacbd\ub85c\ub97c \ubc18\ud658\ud574\uc694. \ub450 \uc778\uc218\uc5d0\ub294 \uacbd\ub85c \ubb38\uc790\uc5f4\uc774\ub098 \uacbd\ub85c \uac1d\uccb4\ub97c \uc4f8 \uc218 \uc788\uc5b4\uc694. \ub300\uc0c1 \uacbd\ub85c\ub294 \ub514\ub809\ud130\ub9ac\ub9cc \uc9c0\uc815\ud574\uc11c\ub294 \uc548 \ub418\uace0, \ud30c\uc77c \uc774\ub984\uae4c\uc9c0 \ud3ec\ud568\ud574\uc57c \ud574\uc694.[1]<\/p>\n<pre><code class=\"language-python\">from pathlib import Path\nimport shutil\n\nsource = Path(&#x27;report.txt&#x27;)\ntarget = Path(&#x27;backup\/report.txt&#x27;)\nshutil.copyfile(source, target)<\/code><\/pre>\n<p>\uc608\uc81c\uc758 <code>backup<\/code> \ub514\ub809\ud130\ub9ac\ub294 \ubbf8\ub9ac \uc900\ube44\ud574\uc57c \ud574\uc694. \ubcf5\uc0ac\ud560 \uc704\uce58\uc5d0 \uc4f0\uae30 \uad8c\ud55c\uc774 \uc5c6\uc73c\uba74 \uc624\ub958\uac00 \ubc1c\uc0dd\ud560 \uc218 \uc788\uace0, \ub300\uc0c1 \ud30c\uc77c\uc774 \uc774\ubbf8 \uc788\uc73c\uba74 \uad50\uccb4\ub3fc\uc694. \uc6d0\ubcf8\uacfc \ub300\uc0c1\uc774 \uac19\uc740 \ud30c\uc77c\uc774\uba74 <code>SameFileError<\/code>\uac00 \ubc1c\uc0dd\ud574\uc694.[1]<\/p>\n<h2>copy: \ud30c\uc77c \ub0b4\uc6a9\uacfc \uad8c\ud55c \ubaa8\ub4dc \ubcf5\uc0ac\ud558\uae30<\/h2>\n<figure><img decoding=\"async\" src=\"https:\/\/danlabs.kr\/wp-content\/uploads\/2026\/11\/dev-20261109-inline2.jpg\" alt=\"\uc6d0\ubcf8\uacfc \ub300\uc0c1 \uacbd\ub85c \ubc0f \uae30\uc874 \ud30c\uc77c \uad50\uccb4\" \/><\/figure>\n<p>\ub300\uc0c1 \ud3f4\ub354\uc5d0 \uc6d0\ubcf8 \ud30c\uc77c \uc774\ub984\uc744 \uadf8\ub300\ub85c \uc720\uc9c0\ud574 \ubcf5\uc0ac\ud558\ub824\uba74 <code>shutil.copy<\/code>\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc788\uc5b4\uc694. \ub300\uc0c1\uc774 \ub514\ub809\ud130\ub9ac\uc774\uba74 \uc6d0\ubcf8\uc758 \uae30\ubcf8 \ud30c\uc77c \uc774\ub984\uc73c\ub85c \uadf8 \uc548\uc5d0 \ubcf5\uc0ac\ud574\uc694.[1]<\/p>\n<pre><code class=\"language-python\">shutil.copy(&#x27;report.txt&#x27;, &#x27;backup\/&#x27;)<\/code><\/pre>\n<p><code>copy<\/code>\ub294 \ud30c\uc77c \ub0b4\uc6a9\uacfc \uad8c\ud55c \ubaa8\ub4dc\ub97c \ubcf5\uc0ac\ud558\uc9c0\ub9cc, \uc0dd\uc131 \uc2dc\uac01\uc774\ub098 \uc218\uc815 \uc2dc\uac01 \uac19\uc740 \ub2e4\ub978 \uba54\ud0c0\ub370\uc774\ud130\ub294 \ubcf4\uc874\ud558\uc9c0 \uc54a\uc544\uc694.[1] \ud30c\uc77c\uc758 \uc2dc\uac01 \uc815\ubcf4\ub97c \uae30\uc900\uc73c\ub85c \uc815\ub82c\ud558\uac70\ub098 \ube44\uad50\ud558\ub294 \uc791\uc5c5\uc5d0\uc11c\ub294 \uc774 \ucc28\uc774\ub97c \ud655\uc778\ud574\uc57c \ud574\uc694.<\/p>\n<h2>copy2: \uba54\ud0c0\ub370\uc774\ud130 \ubcf4\uc874\uc744 \uc2dc\ub3c4\ud558\uc9c0\ub9cc \ubcf4\uc7a5 \ubc94\uc704\ub294 \uc81c\ud55c\uc801<\/h2>\n<p><code>shutil.copy2<\/code>\ub294 <code>copy<\/code>\ucc98\ub7fc \ud30c\uc77c\uc744 \ubcf5\uc0ac\ud558\uba74\uc11c \uba54\ud0c0\ub370\uc774\ud130 \ubcf4\uc874\ub3c4 \uc2dc\ub3c4\ud574\uc694.[1] \uc6d0\ubcf8\uc758 \uc218\uc815 \uc2dc\uac01\uc744 \uc720\uc9c0\ud574\uc57c \ud560 \ub54c \uac80\ud1a0\ud560 \uc218 \uc788\uc9c0\ub9cc, \ubaa8\ub4e0 \uc2dc\uc2a4\ud15c \uc815\ubcf4\uac00 \uadf8\ub300\ub85c \uc62e\uaca8\uc9c0\ub294 \uac83\uc740 \uc544\ub2c8\uc5d0\uc694.<\/p>\n<p>Python \ubb38\uc11c\ub294 \uace0\uc218\uc900 \ubcf5\uc0ac \ud568\uc218\ub3c4 \ubaa8\ub4e0 \uba54\ud0c0\ub370\uc774\ud130\ub97c \ubcf5\uc0ac\ud558\uc9c0 \ubabb\ud55c\ub2e4\uace0 \uacbd\uace0\ud574\uc694. POSIX\uc5d0\uc11c\ub294 \uc18c\uc720\uc790\u00b7\uadf8\ub8f9\uacfc ACL\uc774 \ubcf4\uc874\ub418\uc9c0 \uc54a\uc73c\uba70, Windows\uc5d0\uc11c\ub3c4 \uc18c\uc720\uc790\u00b7ACL\u00b7\ub300\uccb4 \ub370\uc774\ud130 \uc2a4\ud2b8\ub9bc\uc740 \ubcf5\uc0ac\ub418\uc9c0 \uc54a\uc544\uc694.[1] \ud544\uc694\ud55c \uc18d\uc131\uc774 \uc720\uc9c0\ub418\ub294\uc9c0\ub294 \uc6b4\uc601\uccb4\uc81c\uc640 \ud30c\uc77c\uc2dc\uc2a4\ud15c\uc5d0 \ub530\ub77c \ubcc4\ub3c4\ub85c \uac80\uc99d\ud574\uc57c \ud574\uc694.<\/p>\n<h2>Python 3.12.3(Linux)\uc5d0\uc11c \ud655\uc778\ud55c \ubcf5\uc0ac \uacb0\uacfc<\/h2>\n<p>\uc774 \uae00\uc744 \ud3b8\uc9d1\ud558\ub294 \uacfc\uc815\uc5d0\uc11c Python 3.12.3(Linux) \uc0cc\ub4dc\ubc15\uc2a4\uc5d0\uc11c \uc9c1\uc811 \uc2e4\ud589\ud574 \ud655\uc778\ud55c \uacb0\uacfc\uc608\uc694. \uad8c\ud55c \ubaa8\ub4dc 0o640\uc778 \uc2dc\ud5d8 \ud30c\uc77c\uc744 \ubcf5\uc0ac\ud588\uc744 \ub54c, <code>copyfile<\/code>\uc740 \ub0b4\uc6a9\uc740 \uac19\uc558\uc9c0\ub9cc \ub300\uc0c1 \uad8c\ud55c\uc774 0o644\uac00 \ub418\uc5c8\uace0 \uc218\uc815 \uc2dc\uac01\ub3c4 \ub2ec\ub77c\uc84c\uc5b4\uc694. \uac19\uc740 \uacbd\ub85c\uc5d0 \ub2e4\uc2dc \ubcf5\uc0ac\ud558\uba74 <code>SameFileError<\/code>\uac00 \ubc1c\uc0dd\ud588\uc5b4\uc694.<\/p>\n<p><code>copy<\/code>\ub294 \ub0b4\uc6a9\uacfc \uad8c\ud55c \ubaa8\ub4dc 0o640\uc744 \uc720\uc9c0\ud588\uc9c0\ub9cc \uc218\uc815 \uc2dc\uac01\uc740 \uc720\uc9c0\ud558\uc9c0 \uc54a\uc558\uc5b4\uc694. <code>copy2<\/code>\ub294 \uc774 \ud658\uacbd\uc5d0\uc11c \ub0b4\uc6a9\u00b7\uad8c\ud55c \ubaa8\ub4dc\u00b7\uc218\uc815 \uc2dc\uac01\uc744 \ubaa8\ub450 \uc720\uc9c0\ud588\uc5b4\uc694. \uc774\ub294 \uc774 \ud55c \ud658\uacbd\uc5d0\uc11c \uad00\ucc30\ud55c \uacb0\uacfc\uc774\uba70, POSIX\uc5d0\uc11c \uc18c\uc720\uc790\u00b7\uadf8\ub8f9\u00b7ACL\uc774 \ubcf4\uc874\ub418\uc9c0 \uc54a\ub294\ub2e4\ub294 \ubb38\uc11c\uc758 \uacbd\uace0\ub97c \ub4a4\uc9d1\uc9c0 \uc54a\uc544\uc694.<\/p>\n<h2>\uc2ec\ubcfc\ub9ad \ub9c1\ud06c\uc640 \ub300\uc0c1 \uacbd\ub85c \ud655\uc778\ud558\uae30<\/h2>\n<p><code>copy<\/code>\uc640 <code>copy2<\/code>\uc5d0\uc11c <code>follow_symlinks=False<\/code>\uc774\uace0 \uc6d0\ubcf8\uc774 \uc2ec\ubcfc\ub9ad \ub9c1\ud06c\ub77c\uba74 \ub300\uc0c1\uc5d0 \ub9c1\ud06c\ub97c \ub9cc\ub4e4\uc5b4\uc694. \uae30\ubcf8\uac12\uc778 <code>True<\/code>\uc5d0\uc11c\ub294 \ub9c1\ud06c\uac00 \uac00\ub9ac\ud0a4\ub294 \ud30c\uc77c\uc744 \ubcf5\uc0ac\ud574\uc694.[1]<\/p>\n<figure><img decoding=\"async\" src=\"https:\/\/danlabs.kr\/wp-content\/uploads\/2026\/11\/dev-20261109-inline3.jpg\" alt=\"\ubcf5\uc0ac \uc804 \uad8c\ud55c\uacfc \uba54\ud0c0\ub370\uc774\ud130, \uc2ec\ubcfc\ub9ad \ub9c1\ud06c \ud655\uc778\" \/><\/figure>\n<p><code>pathlib.Path<\/code> \uac1d\uccb4\ub3c4 \ubcf5\uc0ac \ud568\uc218\uc758 \uc778\uc218\ub85c \uc0ac\uc6a9\ud560 \uc218 \uc788\uc5b4\uc694. \uacbd\ub85c\ub97c <code>\/<\/code> \uc5f0\uc0b0\uc790\ub85c \uc870\ud569\ud560 \uc218 \uc788\uc5b4 \ub300\uc0c1 \ud30c\uc77c\uc744 \uba85\uc2dc\ud560 \ub54c \ud3b8\ub9ac\ud574\uc694.[1][2] \ud30c\uc77c \uc774\ub984\uc73c\ub85c \ucc3e\ub294 \ubc29\ubc95\uc740 <a href=\"https:\/\/danlabs.kr\/?p=1890\">Python glob \uc548\ub0b4<\/a>\uc5d0\uc11c \ub530\ub85c \ub2e4\ub918\uc5b4\uc694.<\/p>\n<p>\uc790\ub3d9\ud654\uc5d0 \ub123\uae30 \uc804\uc5d0\ub294 \uc791\uc740 \uc2dc\ud5d8 \ub514\ub809\ud130\ub9ac\uc5d0\uc11c \ubcf5\uc0ac \uacb0\uacfc\ub97c \ud655\uc778\ud558\uc138\uc694. \uc608\uc81c\ub3c4 \uc2e4\uc81c \ud30c\uc77c\uc744 \ub36e\uc5b4\uc4f8 \uc218 \uc788\uc73c\ubbc0\ub85c \uc911\uc694\ud55c \uc6d0\ubcf8\uc774\ub098 \uae30\uc874 \ubc31\uc5c5\uc5d0 \ubc14\ub85c \uc801\uc6a9\ud558\uc9c0 \ub9d0\uace0, \ub2e4\uc74c \uc0ac\ud56d\uc744 \uba3c\uc800 \ud655\uc778\ud558\ub294 \ud3b8\uc774 \uc548\uc804\ud574\uc694.<\/p>\n<ul>\n<li><code>copyfile<\/code>\uc758 \ub300\uc0c1 \uacbd\ub85c\uc5d0 \ud30c\uc77c \uc774\ub984\uc774 \ud3ec\ud568\ub418\uc5b4 \uc788\ub294\uc9c0<\/li>\n<li>\uae30\uc874 \ub300\uc0c1 \ud30c\uc77c\uc744 \uad50\uccb4\ud574\ub3c4 \ub418\ub294\uc9c0<\/li>\n<li>\ud544\uc694\ud55c \uba54\ud0c0\ub370\uc774\ud130\uc758 \ubcf4\uc874 \ubc94\uc704\uc640 \uc2ec\ubcfc\ub9ad \ub9c1\ud06c \ucc98\ub9ac \ubc29\uc2dd\uc774 \ub9de\ub294\uc9c0<\/li>\n<\/ul>\n<h2>\ucc38\uace0 \ubb38\uc11c<\/h2>\n<p>\ud568\uc218\ubcc4 \ubcf5\uc0ac \ubc94\uc704\uc640 \uba54\ud0c0\ub370\uc774\ud130\u00b7\uc2ec\ubcfc\ub9ad \ub9c1\ud06c \ucc98\ub9ac \uc870\uac74\uc740 shutil \ubb38\uc11c\uc5d0\uc11c, \uacbd\ub85c \uac1d\uccb4 \uc0ac\uc6a9\ubc95\uc740 pathlib \ubb38\uc11c\uc5d0\uc11c \ud655\uc778\ud560 \uc218 \uc788\uc5b4\uc694.<\/p>\n<p>[1] <a href=\"https:\/\/docs.python.org\/3\/library\/shutil.html\" target=\"_blank\" rel=\"noopener noreferrer\">Python shutil documentation (2026-11-09 \uc870\ud68c)<\/a><\/p>\n<p>[2] <a href=\"https:\/\/docs.python.org\/3\/library\/pathlib.html\" target=\"_blank\" rel=\"noopener noreferrer\">Python pathlib documentation (2026-11-09 \uc870\ud68c)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>shutil\ub85c \ud30c\uc77c\uc744 \ubcf5\uc0ac\ud574\ub3c4 \uad8c\ud55c\uacfc \uc2dc\uac04 \uc815\ubcf4\uac00 \ubaa8\ub450 \uc720\uc9c0\ub418\ub294 \uac83\uc740 \uc544\ub2c8\uc5d0\uc694. copyfile\uc740 \ub0b4\uc6a9\ub9cc, copy\ub294 \ub0b4\uc6a9\uacfc \uad8c\ud55c \ubaa8\ub4dc\ub97c \ubcf5\uc0ac\ud558\uace0 copy2\ub294 \ucd94\uac00 \uba54\ud0c0\ub370\uc774\ud130 \ubcf4\uc874\uc744 \uc2dc\ub3c4\ud574\uc694. Linux \uc2e4\ud589 \uacb0\uacfc\uc640 \uc2dc\uc2a4\ud15c\ubcc4 \ubcf4\uc874 \ud55c\uacc4\ub3c4 \ud568\uaed8 \uc9da\uc5b4\uc694.<\/p>\n","protected":false},"author":1,"featured_media":2397,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-2236","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev"],"featured_image_urls":{"full":["https:\/\/danlabs.kr\/wp-content\/uploads\/2026\/11\/python-shutil-copy-copy2-metadata-2236-concept.webp",1536,1024,false],"thumbnail":["https:\/\/danlabs.kr\/wp-content\/uploads\/2026\/11\/python-shutil-copy-copy2-metadata-2236-concept-150x150.webp",150,150,true],"medium":["https:\/\/danlabs.kr\/wp-content\/uploads\/2026\/11\/python-shutil-copy-copy2-metadata-2236-concept-300x200.webp",300,200,true],"medium_large":["https:\/\/danlabs.kr\/wp-content\/uploads\/2026\/11\/python-shutil-copy-copy2-metadata-2236-concept-768x512.webp",640,427,true],"large":["https:\/\/danlabs.kr\/wp-content\/uploads\/2026\/11\/python-shutil-copy-copy2-metadata-2236-concept-1024x683.webp",640,427,true],"1536x1536":["https:\/\/danlabs.kr\/wp-content\/uploads\/2026\/11\/python-shutil-copy-copy2-metadata-2236-concept.webp",1536,1024,false],"2048x2048":["https:\/\/danlabs.kr\/wp-content\/uploads\/2026\/11\/python-shutil-copy-copy2-metadata-2236-concept.webp",1536,1024,false],"morenews-large":["https:\/\/danlabs.kr\/wp-content\/uploads\/2026\/11\/python-shutil-copy-copy2-metadata-2236-concept.webp",825,550,false],"morenews-medium":["https:\/\/danlabs.kr\/wp-content\/uploads\/2026\/11\/python-shutil-copy-copy2-metadata-2236-concept.webp",590,393,false],"danlabs-list-small":["https:\/\/danlabs.kr\/wp-content\/uploads\/2026\/11\/python-shutil-copy-copy2-metadata-2236-concept-366x190.webp",366,190,true],"danlabs-list-retina":["https:\/\/danlabs.kr\/wp-content\/uploads\/2026\/11\/python-shutil-copy-copy2-metadata-2236-concept-1464x760.webp",1464,760,true]},"author_info":{"display_name":"DanLABs","author_link":"https:\/\/danlabs.kr\/author\/hello-danlabs-kr"},"category_info":"<a href=\"https:\/\/danlabs.kr\/?cat=19\" rel=\"category\">\uac1c\ubc1c<\/a>","tag_info":"\uac1c\ubc1c","comment_count":"0","_links":{"self":[{"href":"https:\/\/danlabs.kr\/index.php?rest_route=\/wp\/v2\/posts\/2236","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/danlabs.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/danlabs.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/danlabs.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/danlabs.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2236"}],"version-history":[{"count":3,"href":"https:\/\/danlabs.kr\/index.php?rest_route=\/wp\/v2\/posts\/2236\/revisions"}],"predecessor-version":[{"id":2372,"href":"https:\/\/danlabs.kr\/index.php?rest_route=\/wp\/v2\/posts\/2236\/revisions\/2372"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/danlabs.kr\/index.php?rest_route=\/wp\/v2\/media\/2397"}],"wp:attachment":[{"href":"https:\/\/danlabs.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/danlabs.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/danlabs.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}