{"id":97712,"date":"2024-03-21T22:29:07","date_gmt":"2024-03-21T13:29:07","guid":{"rendered":"https:\/\/www.silicloud.com\/ja\/blog\/%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e5%86%85%e3%81%aepython%e3%81%ae%e5%87%a6%e7%90%86\/"},"modified":"2024-03-27T11:52:53","modified_gmt":"2024-03-27T02:52:53","slug":"%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e5%86%85%e3%81%aepython%e3%81%ae%e5%87%a6%e7%90%86","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/ja\/blog\/%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e5%86%85%e3%81%aepython%e3%81%ae%e5%87%a6%e7%90%86\/","title":{"rendered":"\u30d5\u30a1\u30a4\u30eb\u5185\u306ePython\u306e\u51e6\u7406"},"content":{"rendered":"<p>Python \u3067\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u6271\u3046\u306b\u306f\u3001os \u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002\u4e00\u822c\u7684\u306a\u30e1\u30bd\u30c3\u30c9\u3092\u4ee5\u4e0b\u306b\u793a\u3057\u307e\u3059\u3002<\/p>\n<ol>\n<li>\u30d5\u30a9\u30eb\u30c0\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308b\uff1a<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><span class=\"hljs-keyword\">import<\/span> os\r\n\r\nfolder_path = <span class=\"hljs-string\">'\/path\/to\/folder'<\/span>\r\nfile_list = os.listdir(folder_path)\r\n<\/code><\/pre>\n<ol>\n<li>\u30d5\u30a9\u30eb\u30c0\u30fc\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u30eb\u30fc\u30d7<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><span class=\"hljs-keyword\">import<\/span> os\r\n\r\nfolder_path = <span class=\"hljs-string\">'\/path\/to\/folder'<\/span>\r\n<span class=\"hljs-keyword\">for<\/span> file_name <span class=\"hljs-keyword\">in<\/span> os.listdir(folder_path):\r\n    file_path = os.path.join(folder_path, file_name)\r\n    <span class=\"hljs-comment\"># \u8fdb\u884c\u76f8\u5e94\u7684\u5904\u7406<\/span>\r\n<\/code><\/pre>\n<ol>\n<li>\u30d5\u30a1\u30a4\u30eb\u304c\u3042\u308b\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3057\u307e\u3059\uff1a<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><span class=\"hljs-keyword\">import<\/span> os\r\n\r\nfile_path = <span class=\"hljs-string\">'\/path\/to\/file'<\/span>\r\n<span class=\"hljs-keyword\">if<\/span> os.path.exists(file_path):\r\n    <span class=\"hljs-comment\"># \u6587\u4ef6\u5b58\u5728<\/span>\r\n<span class=\"hljs-keyword\">else<\/span>:\r\n    <span class=\"hljs-comment\"># \u6587\u4ef6\u4e0d\u5b58\u5728<\/span>\r\n<\/code><\/pre>\n<ol>\n<li>\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210\u3059\u308b:<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><span class=\"hljs-keyword\">import<\/span> os\r\n\r\nfolder_path = <span class=\"hljs-string\">'\/path\/to\/folder'<\/span>\r\nos.makedirs(folder_path, exist_ok=<span class=\"hljs-literal\">True<\/span>)\r\n<\/code><\/pre>\n<ol>\n<li>\u30d5\u30a1\u30a4\u30eb\u3092\u30b3\u30d4\u30fc<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><span class=\"hljs-keyword\">import<\/span> shutil\r\n\r\nsource_file = <span class=\"hljs-string\">'\/path\/to\/source_file'<\/span>\r\ndestination_folder = <span class=\"hljs-string\">'\/path\/to\/destination_folder'<\/span>\r\nshutil.copy(source_file, destination_folder)\r\n<\/code><\/pre>\n<ol>\n<li>\u30d5\u30a1\u30a4\u30eb\u3092\u524a\u9664\u3059\u308b<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><span class=\"hljs-keyword\">import<\/span> os\r\n\r\nfile_path = <span class=\"hljs-string\">'\/path\/to\/file'<\/span>\r\nos.remove(file_path)\r\n<\/code><\/pre>\n<p>\u7279\u5b9a\u306e\u30cb\u30fc\u30ba\u306b\u5408\u308f\u305b\u3066\u3001\u30d5\u30a9\u30eb\u30c0\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u9069\u5207\u306b\u51e6\u7406\u3059\u308b\u305f\u3081\u306e\u65b9\u6cd5\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python \u3067\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u6271\u3046\u306b\u306f\u3001os \u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002\u4e00\u822c\u7684\u306a\u30e1\u30bd\u30c3\u30c9\u3092\u4ee5\u4e0b\u306b\u793a\u3057\u307e\u3059\u3002 \u30d5\u30a9\u30eb\u30c0\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308b\uff1a import os folder_path = &#8216;\/path\/ [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-97712","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u30d5\u30a1\u30a4\u30eb\u5185\u306ePython\u306e\u51e6\u7406 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/ja\/blog\/\u30d5\u30a1\u30a4\u30eb\u5185\u306epython\u306e\u51e6\u7406\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u30d5\u30a1\u30a4\u30eb\u5185\u306ePython\u306e\u51e6\u7406\" \/>\n<meta property=\"og:description\" content=\"Python \u3067\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u6271\u3046\u306b\u306f\u3001os \u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002\u4e00\u822c\u7684\u306a\u30e1\u30bd\u30c3\u30c9\u3092\u4ee5\u4e0b\u306b\u793a\u3057\u307e\u3059\u3002 \u30d5\u30a9\u30eb\u30c0\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308b\uff1a import os folder_path = &#039;\/path\/ [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/ja\/blog\/\u30d5\u30a1\u30a4\u30eb\u5185\u306epython\u306e\u51e6\u7406\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-21T13:29:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-27T02:52:53+00:00\" \/>\n<meta name=\"author\" content=\"\u84ee, \u7ffc\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u57f7\u7b46\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u84ee, \u7ffc\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"1\u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e5%86%85%e3%81%aepython%e3%81%ae%e5%87%a6%e7%90%86\/\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e5%86%85%e3%81%aepython%e3%81%ae%e5%87%a6%e7%90%86\/\",\"name\":\"\u30d5\u30a1\u30a4\u30eb\u5185\u306ePython\u306e\u51e6\u7406 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\"},\"datePublished\":\"2024-03-21T13:29:07+00:00\",\"dateModified\":\"2024-03-27T02:52:53+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/cdc124a0aaebf26393d8d591183ca413\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e5%86%85%e3%81%aepython%e3%81%ae%e5%87%a6%e7%90%86\/#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/ja\/blog\/%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e5%86%85%e3%81%aepython%e3%81%ae%e5%87%a6%e7%90%86\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e5%86%85%e3%81%aepython%e3%81%ae%e5%87%a6%e7%90%86\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/ja\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u30d5\u30a1\u30a4\u30eb\u5185\u306ePython\u306e\u51e6\u7406\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"ja\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/cdc124a0aaebf26393d8d591183ca413\",\"name\":\"\u84ee, \u7ffc\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/27308f733c7fcdac8617926a0100c77213339c4e501310a08c0baf946bf823bc?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/27308f733c7fcdac8617926a0100c77213339c4e501310a08c0baf946bf823bc?s=96&d=mm&r=g\",\"caption\":\"\u84ee, \u7ffc\"},\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/author\/rentsubasa\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e5%86%85%e3%81%aepython%e3%81%ae%e5%87%a6%e7%90%86\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u30d5\u30a1\u30a4\u30eb\u5185\u306ePython\u306e\u51e6\u7406 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/ja\/blog\/\u30d5\u30a1\u30a4\u30eb\u5185\u306epython\u306e\u51e6\u7406\/","og_locale":"ja_JP","og_type":"article","og_title":"\u30d5\u30a1\u30a4\u30eb\u5185\u306ePython\u306e\u51e6\u7406","og_description":"Python \u3067\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u6271\u3046\u306b\u306f\u3001os \u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002\u4e00\u822c\u7684\u306a\u30e1\u30bd\u30c3\u30c9\u3092\u4ee5\u4e0b\u306b\u793a\u3057\u307e\u3059\u3002 \u30d5\u30a9\u30eb\u30c0\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308b\uff1a import os folder_path = '\/path\/ [&hellip;]","og_url":"https:\/\/www.silicloud.com\/ja\/blog\/\u30d5\u30a1\u30a4\u30eb\u5185\u306epython\u306e\u51e6\u7406\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2024-03-21T13:29:07+00:00","article_modified_time":"2024-03-27T02:52:53+00:00","author":"\u84ee, \u7ffc","twitter_card":"summary_large_image","twitter_misc":{"\u57f7\u7b46\u8005":"\u84ee, \u7ffc","\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593":"1\u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/ja\/blog\/%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e5%86%85%e3%81%aepython%e3%81%ae%e5%87%a6%e7%90%86\/","url":"https:\/\/www.silicloud.com\/ja\/blog\/%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e5%86%85%e3%81%aepython%e3%81%ae%e5%87%a6%e7%90%86\/","name":"\u30d5\u30a1\u30a4\u30eb\u5185\u306ePython\u306e\u51e6\u7406 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website"},"datePublished":"2024-03-21T13:29:07+00:00","dateModified":"2024-03-27T02:52:53+00:00","author":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/cdc124a0aaebf26393d8d591183ca413"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e5%86%85%e3%81%aepython%e3%81%ae%e5%87%a6%e7%90%86\/#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/ja\/blog\/%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e5%86%85%e3%81%aepython%e3%81%ae%e5%87%a6%e7%90%86\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/ja\/blog\/%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e5%86%85%e3%81%aepython%e3%81%ae%e5%87%a6%e7%90%86\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/ja\/blog\/"},{"@type":"ListItem","position":2,"name":"\u30d5\u30a1\u30a4\u30eb\u5185\u306ePython\u306e\u51e6\u7406"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website","url":"https:\/\/www.silicloud.com\/ja\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"ja"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/cdc124a0aaebf26393d8d591183ca413","name":"\u84ee, \u7ffc","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/27308f733c7fcdac8617926a0100c77213339c4e501310a08c0baf946bf823bc?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/27308f733c7fcdac8617926a0100c77213339c4e501310a08c0baf946bf823bc?s=96&d=mm&r=g","caption":"\u84ee, \u7ffc"},"url":"https:\/\/www.silicloud.com\/ja\/blog\/author\/rentsubasa\/"},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e5%86%85%e3%81%aepython%e3%81%ae%e5%87%a6%e7%90%86\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/97712","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/comments?post=97712"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/97712\/revisions"}],"predecessor-version":[{"id":188629,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/97712\/revisions\/188629"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/media?parent=97712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/categories?post=97712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/tags?post=97712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}