{"id":2160,"date":"2019-06-17T19:22:56","date_gmt":"2019-06-17T17:22:56","guid":{"rendered":"https:\/\/pythonprogramming.altervista.org\/?p=2160"},"modified":"2019-06-17T19:22:56","modified_gmt":"2019-06-17T17:22:56","slug":"how-to-copy-a-file-with-python-and-shutil-ecc","status":"publish","type":"post","link":"https:\/\/pythonprogramming.altervista.org\/how-to-copy-a-file-with-python-and-shutil-ecc\/","title":{"rendered":"How to copy a file with Python and shutil ecc."},"content":{"rendered":"<p>Here is some code to copy a file with shutil.<\/p>\n<pre class=\"lang:default decode:true \"># copy a file\r\n\r\nimport shutil\r\n\r\n# copy the file file.txt in the backup folder\r\nshutil.copy(\"file.txt\", \"backup\")<\/pre>\n<p>or this way &#8230;<\/p>\n<pre class=\"lang:default decode:true \">with open(\"file.txt\", \"rb\") as read:\r\n\twith open(\"backup\/file2.txt\", \"wb\") as filetobecopied:\r\n\t\tfiletobecopied.write(read.read())<\/pre>\n<p>This is the video about these methods of copying files.<\/p>\n<p><iframe loading=\"lazy\" title=\"How to copy a file with Python\" width=\"747\" height=\"420\" src=\"https:\/\/www.youtube.com\/embed\/pMGUsG8QCrw?feature=oembed&amp;enablejsapi=1\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"How to copy files with Python and shutil or with open&#8230; two ways of doing the same thing,\n<a class=\"moretag\" href=\"https:\/\/pythonprogramming.altervista.org\/how-to-copy-a-file-with-python-and-shutil-ecc\/\"> [...]<\/a>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[1],"tags":[25],"class_list":["post-2160","post","type-post","status-publish","format-standard","hentry","category-examples","tag-shutil"],"avopt_banners_inside_post":true,"avopt_banners_on_page":true,"av_copy_from":"","av_sharing_message":"","av_sharing_allowed":false,"av_sharing_on":{"fb":[],"tw":[]},"av_allow_affiliate_banner":false,"av_allow_affiliate_multi_banner":false,"av_show_affiliation_buy_button":false,"av_post_rating":true,"av_have_post_rating_value":false,"av_is_artificial_intelligence_content":false,"_links":{"self":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/2160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/comments?post=2160"}],"version-history":[{"count":1,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/2160\/revisions"}],"predecessor-version":[{"id":2161,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/2160\/revisions\/2161"}],"wp:attachment":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media?parent=2160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/categories?post=2160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/tags?post=2160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}