{"id":15936,"date":"2021-08-22T08:37:49","date_gmt":"2021-08-22T03:07:49","guid":{"rendered":"http:\/\/www.pythonpool.com\/?p=15936"},"modified":"2021-08-22T08:41:40","modified_gmt":"2021-08-22T03:11:40","slug":"python-touch-file","status":"publish","type":"post","link":"https:\/\/www.pythonpool.com\/python-touch-file\/","title":{"rendered":"Python Touch File | How To Implement Touch Files"},"content":{"rendered":"\n<p>In this article, we are going to learn about python touch files. With that, we will learn how to implement touch files in python. Simply, we can say we will learn how to create a new file in a particular path with a particular extension. To implement this, we are using some modules. We will learn about all of this in a detailed manner.<\/p>\n\n\n\n<p><strong>To create a new file in a needed directory, we can either use path.touch() function or touch module. Both of them play a similar role. The only difference is that it is implementing using the pathlib module. We can&#8217;t create multiple files at a time. And using the touch module, we can create multiple files at a time.<\/strong><\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_74 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #990303;color:#990303\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #990303;color:#990303\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.pythonpool.com\/python-touch-file\/#What_is_Pathtouch\" >What is Path.touch()?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/python-touch-file\/#Installation_of_pathlib\" >Installation of pathlib<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/python-touch-file\/#What_are_the_syntax_and_parameters_of_touch_file_in_Python\" >What are the syntax, and parameters of touch file in Python?<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/python-touch-file\/#Syntax\" >Syntax<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/python-touch-file\/#Parameter\" >Parameter<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pythonpool.com\/python-touch-file\/#Using_pathtouch_to_create_a_file_in_the_same_directory\" >Using path.touch to create a file in the same directory<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pythonpool.com\/python-touch-file\/#Using_pathtouch_to_create_a_file_in_another_directory\" >Using path.touch to create a file in another directory<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.pythonpool.com\/python-touch-file\/#What_is_a_touch_module\" >What is a touch module?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.pythonpool.com\/python-touch-file\/#Installation_of_the_touch_module\" >Installation of the touch module<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.pythonpool.com\/python-touch-file\/#Using_touch_module_to_create_a_file_in_a_same_directory\" >Using touch module to create a file in a same directory<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.pythonpool.com\/python-touch-file\/#Using_touch_module_to_create_a_file_in_another_directory\" >Using touch module to create a file in another directory<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.pythonpool.com\/python-touch-file\/#Using_touch_module_to_create_a_multiple_files\" >Using touch module to create a multiple files<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.pythonpool.com\/python-touch-file\/#Create_a_file_if_not_exists\" >Create a file if not exists<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.pythonpool.com\/python-touch-file\/#FAQs_Related_to_Touch_File_in_Python\" >FAQs Related to Touch File in Python<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.pythonpool.com\/python-touch-file\/#Final_Words\" >Final Words<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/www.pythonpool.com\/python-touch-file\/#Trending_Python_Articles\" >Trending Python Articles<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-what-is-path-touch\"><span class=\"ez-toc-section\" id=\"What_is_Pathtouch\"><\/span>What is Path.touch()?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Path.touch is a function that is already available in the pathlib module. This path.touch() function is useful to create a file in a current working directory or some other specified directory. But we can&#8217;t create multiple files at a time.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-installation-of-pathlib\"><span class=\"ez-toc-section\" id=\"Installation_of_pathlib\"><\/span>Installation of pathlib <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you are using python 3.x, then no need to install the pathlib module. It is inbuilt in python. If you are using python 2.x then you have to install the pathlib module by using the command line:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pip install pathlib<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-are-the-syntax-and-parameters-of-touch-file-in-python\"><span class=\"ez-toc-section\" id=\"What_are_the_syntax_and_parameters_of_touch_file_in_Python\"><\/span>What are the syntax, and parameters of touch file in Python?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-syntax\"><span class=\"ez-toc-section\" id=\"Syntax\"><\/span>Syntax<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">Path.touch(mode=0o666, exist_ok=True)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-parameter\"><span class=\"ez-toc-section\" id=\"Parameter\"><\/span>Parameter<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>mode: In which mode do we have to create a file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-using-path-touch-to-create-a-file-in-the-same-directory\"><span class=\"ez-toc-section\" id=\"Using_pathtouch_to_create_a_file_in_the_same_directory\"><\/span>Using path.touch to create a file in the same directory<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfrom pathlib import Path\nPath(&quot;file.py&quot;).touch()\nprint(&quot;File is created in a current working directory&quot;)\n<\/pre><\/div>\n\n\n<p>Using path.touch() function to create a python file in the same directory. I am following the syntax. So if the file is created successfully, it will display the statement like &#8220;File is created in a current working directory&#8221;.<\/p>\n\n\n\n<p class=\"has-medium-font-size\" id=\"h-output\"><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">File is created in current working directory<\/pre>\n\n\n\n<p>Now we can check in python programs whether the file is there or not.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-53.png\" alt=\"python touch files\" class=\"wp-image-15965\" width=\"704\" height=\"110\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-53.png 601w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-53-300x47.png 300w\" sizes=\"(max-width: 704px) 100vw, 704px\" \/><\/figure>\n\n\n\n<p>You can see that file in the same path.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Using_pathtouch_to_create_a_file_in_another_directory\"><\/span>Using path.touch to create a file in another directory<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfrom pathlib import Path\nPath(&quot;E:\/files\/python created this file.txt&quot;).touch()\nprint(&quot;File is created in a specified directory&quot;)\n<\/pre><\/div>\n\n\n<p>Using path.touch() function to create a python file in some other directory. I am following the syntax. So if the file is created successfully, it will display the statement like &#8220;File is created in a specified directory&#8221;.<\/p>\n\n\n\n<p class=\"has-medium-font-size\" id=\"h-output-1\"><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">File is created in a specified directory<\/pre>\n\n\n\n<p>Now we can check in a specified folder whether the file is there or not. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-55.png\" alt=\"Using path.touch to create a file in another directory\" class=\"wp-image-15968\" width=\"706\" height=\"165\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-55.png 732w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-55-300x70.png 300w\" sizes=\"(max-width: 706px) 100vw, 706px\" \/><\/figure>\n\n\n\n<p> You can see that file in a specified path.  <\/p>\n\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-kilo monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Popular now<\/span><span class=\"monsterinsights-inline-popular-posts-border\" ><\/span><span class=\"monsterinsights-inline-popular-posts-border-2\" ><\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-cant-compare-datetime-datetime-to-datetime-date\/\">[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-is-a-touch-module\"><span class=\"ez-toc-section\" id=\"What_is_a_touch_module\"><\/span>What is a touch module?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The touch module is also useful to create a new file like the pathlib module. We need to install a module library. This module is useful to create a file in a current working directory or some other specified directory. And also, we can create multiple files at a time. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-installation-of-the-touch-module\"><span class=\"ez-toc-section\" id=\"Installation_of_the_touch_module\"><\/span>Installation of the touch module<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The pip command to install the touch module is:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pip install touch<\/pre>\n\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-juliett monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-image\"><a href=\"https:\/\/www.pythonpool.com\/fixed-nameerror-name-unicode-is-not-defined\/\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined.webp 1200w \" alt=\"[Fixed] nameerror: name Unicode is not defined\" \/><\/a><\/div><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Trending<\/span><span class=\"monsterinsights-inline-popular-posts-border\" ><\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/fixed-nameerror-name-unicode-is-not-defined\/\">[Fixed] nameerror: name Unicode is not defined<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-using-touch-module-to-create-a-file-in-a-same-directory\"><span class=\"ez-toc-section\" id=\"Using_touch_module_to_create_a_file_in_a_same_directory\"><\/span>Using touch module to create a file in a same directory <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport touch\ntouch.touch(&quot;test.py&quot;)\nprint(&quot;File is created in a current working directory&quot;)\n<\/pre><\/div>\n\n\n<p>Using touch module to create a python file in the same directory. If the file is created successfully, it will display a statement like &#8220;File is created in a current working directory&#8221;. <\/p>\n\n\n\n<p class=\"has-medium-font-size\" id=\"h-output-2\"><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">File is created in a current working directory<\/pre>\n\n\n\n<p>Now we can check in python programs whether the file is there or not. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-57.png\" alt=\"Using touch module to create a file in a same directory \" class=\"wp-image-15972\" width=\"701\" height=\"168\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-57.png 564w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-57-300x72.png 300w\" sizes=\"(max-width: 701px) 100vw, 701px\" \/><\/figure>\n\n\n\n<p>You can see that file in the same file path.  <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-using-touch-module-to-create-a-file-in-another-directory\"><span class=\"ez-toc-section\" id=\"Using_touch_module_to_create_a_file_in_another_directory\"><\/span>Using touch module to create a file in another directory <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport touch\ntouch.touch(&quot;E:\/files\/new file.txt&quot;)\nprint(&quot;File is created in a specified directory&quot;)\n<\/pre><\/div>\n\n\n<p>Using touch module to create a python file in a specified <a href=\"https:\/\/en.wikipedia.org\/wiki\/Directory\" target=\"_blank\" rel=\"noreferrer noopener\">directory<\/a>. If the file is created successfully, it will display a statement like &#8220;File is created in a specified directory&#8221;. <\/p>\n\n\n\n<p class=\"has-medium-font-size\" id=\"h-output-3\"><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">File is created in a specified directory<\/pre>\n\n\n\n<p>Now we can check in a specified folder whether the file is there or not.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"692\" height=\"251\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-59.png\" alt=\"Using touch module to create a file in another directory \" class=\"wp-image-15973\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-59.png 692w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-59-300x109.png 300w\" sizes=\"(max-width: 692px) 100vw, 692px\" \/><\/figure>\n\n\n\n<p> You can see that file in a specified path.   <\/p>\n\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-foxtrot monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-image\"><a href=\"https:\/\/www.pythonpool.com\/solved-runtimeerror-cuda-error-invalid-device-ordinal\/\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal.webp 1200w \" alt=\"[Solved] runtimeerror: cuda error: invalid device ordinal\" \/><\/a><\/div><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Trending<\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/solved-runtimeerror-cuda-error-invalid-device-ordinal\/\">[Solved] runtimeerror: cuda error: invalid device ordinal<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-using-touch-module-to-create-a-multiple-files\"><span class=\"ez-toc-section\" id=\"Using_touch_module_to_create_a_multiple_files\"><\/span>Using touch module to create a multiple files<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport touch  \ntouch.touch(&#x5B;&quot;E:\/files\/success file1.txt&quot;, &quot;E:\/files\/success file2.txt&quot;])\nprint(&quot;Multiple files are created successfully&quot;)\n<\/pre><\/div>\n\n\n<p>Importing touch module. Here we are going to create multiple files at the same time. To create multiple files, we have to give the file names in a list. If the file is created successfully, it will display a statement like &#8220;Multiple files are created successfully&#8221;.<\/p>\n\n\n\n<p class=\"has-medium-font-size\" id=\"h-output-4\"><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Multiple files are created successfully<\/pre>\n\n\n\n<p>Now we can check in a specified folder whether the files are there or not.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-61.png\" alt=\"Using touch module to create a multiple files\" class=\"wp-image-15976\" width=\"703\" height=\"289\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-61.png 863w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-61-300x124.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-61-768x317.png 768w\" sizes=\"(max-width: 703px) 100vw, 703px\" \/><\/figure>\n\n\n\n<p>You can see that files are in a specified path.   <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-create-a-file-if-not-exists\"><span class=\"ez-toc-section\" id=\"Create_a_file_if_not_exists\"><\/span>Create a file if not exists<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfrom pathlib import Path\nPath(&quot;E:\/files\/exist.txt&quot;).touch(exist_ok=True)\n<\/pre><\/div>\n\n\n<p>exist_ok creates a new file if the file does not exist. If the <a href=\"http:\/\/www.pythonpool.com\/python-check-if-file-exists\/\" target=\"_blank\" rel=\"noreferrer noopener\"><span style=\"text-decoration: underline;\"><strong>file already exists<\/strong><\/span><\/a>, it will do nothing to that. Simply it leaves that as it is.<\/p>\n\n\n\n<p>Now I&#8217;m trying to create a new file. Let us see whether the new file is created or not.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"687\" height=\"352\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-64.png\" alt=\"Create a file if not exists\" class=\"wp-image-15985\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-64.png 687w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-64-300x154.png 300w\" sizes=\"(max-width: 687px) 100vw, 687px\" \/><\/figure>\n\n\n\n<p>A new file named <strong>exist <\/strong>is created. <\/p>\n\n\n\n<p>Now we will try this code with an existing file.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfrom pathlib import Path\nPath(&quot;E:\/files\/newfile.txt&quot;).touch(exist_ok=True)\n<\/pre><\/div>\n\n\n<p>The file named <strong>new file already exists<\/strong> in a specified directory, so it did nothing with that.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"636\" height=\"300\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-66.png\" alt=\"new file already exists python touch file\" class=\"wp-image-15986\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-66.png 636w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-66-300x142.png 300w\" sizes=\"(max-width: 636px) 100vw, 636px\" \/><\/figure>\n\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-alpha monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Trending<\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-type-numpy-ndarray-doesnt-define-__round__-method\/\">[Fixed] typeerror: type numpy.ndarray doesn&#8217;t define __round__ method<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-faqs-related-to-touch-file-in-python\"><span class=\"ez-toc-section\" id=\"FAQs_Related_to_Touch_File_in_Python\"><\/span>FAQs Related to Touch File in Python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1629553255487\"><strong class=\"schema-faq-question\">1. How to implement touch files in python?<\/strong> <p class=\"schema-faq-answer\">We can use the pathlib module to implement the touch file in python.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1629553500934\"><strong class=\"schema-faq-question\">2. How can we create a new file in python?<\/strong> <p class=\"schema-faq-answer\">We can use a path.touch() function and touch module to create new files.<\/p> <\/div> <\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-final-words\"><span class=\"ez-toc-section\" id=\"Final_Words\"><\/span>Final Words<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here we came to the end of the article. We have learned about the touch file in python. And also, we learned about the path.touch(), and touch module. This article is beneficial to learn. Creating a new file is our day-to-day application. So doing that with python is awesome. Try to code on your own. Learn python with us!<\/p>\n\n\n<div class=\"monsterinsights-widget-popular-posts monsterinsights-widget-popular-posts-charlie monsterinsights-popular-posts-styled monsterinsights-widget-popular-posts-columns-1\"><h2 class=\"monsterinsights-widget-popular-posts-widget-title\"><span class=\"ez-toc-section\" id=\"Trending_Python_Articles\"><\/span>Trending Python Articles<span class=\"ez-toc-section-end\"><\/span><\/h2><ul class=\"monsterinsights-widget-popular-posts-list\"><li style=\"background-color:#c1e0f3;border-color:#064f7d;\"><a href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-cant-compare-datetime-datetime-to-datetime-date\/\"><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" style=\"color:#000000;font-size:18px;\">[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><\/div><\/div><\/a><\/li><li style=\"background-color:#c1e0f3;border-color:#064f7d;\"><a href=\"https:\/\/www.pythonpool.com\/fixed-nameerror-name-unicode-is-not-defined\/\"><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" style=\"color:#000000;font-size:18px;\">[Fixed] nameerror: name Unicode is not defined<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><\/div><\/div><\/a><\/li><li style=\"background-color:#c1e0f3;border-color:#064f7d;\"><a href=\"https:\/\/www.pythonpool.com\/solved-runtimeerror-cuda-error-invalid-device-ordinal\/\"><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" style=\"color:#000000;font-size:18px;\">[Solved] runtimeerror: cuda error: invalid device ordinal<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><\/div><\/div><\/a><\/li><li style=\"background-color:#c1e0f3;border-color:#064f7d;\"><a href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-type-numpy-ndarray-doesnt-define-__round__-method\/\"><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" style=\"color:#000000;font-size:18px;\">[Fixed] typeerror: type numpy.ndarray doesn&#8217;t define __round__ method<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><\/div><\/div><\/a><\/li><\/ul><\/div><p><\/p>","protected":false},"excerpt":{"rendered":"<p>In this article, we are going to learn about python touch files. With that, we will learn how to implement touch files in python. Simply, &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Python Touch File | How To Implement Touch Files\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/python-touch-file\/#more-15936\" aria-label=\"More on Python Touch File | How To Implement Touch Files\">Read more<\/a><\/p>\n","protected":false},"author":22,"featured_media":15992,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[15],"tags":[],"class_list":["post-15936","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","infinite-scroll-item"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v25.0) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python Touch File | How To Implement Touch Files - Python Pool<\/title>\n<meta name=\"description\" content=\"In this article, we are going to learn about the python touch file. With that, we will learn how to implement touch files in python.\" \/>\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.pythonpool.com\/python-touch-file\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Touch File | How To Implement Touch Files\" \/>\n<meta property=\"og:description\" content=\"In this article, we are going to learn about python touch files. With that, we will learn how to implement touch files in python. Simply, we can say we\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/python-touch-file\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-22T03:07:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-22T03:11:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Python-Touch-File.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Priyalakshmi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:site\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Priyalakshmi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pythonpool.com\/python-touch-file\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-touch-file\/\"},\"author\":{\"name\":\"Priyalakshmi\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/83e6e22a6c461cc1a8445bb473db2f20\"},\"headline\":\"Python Touch File | How To Implement Touch Files\",\"datePublished\":\"2021-08-22T03:07:49+00:00\",\"dateModified\":\"2021-08-22T03:11:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-touch-file\/\"},\"wordCount\":873,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-touch-file\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Python-Touch-File.webp\",\"articleSection\":[\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com\/python-touch-file\/#respond\"]}]},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\/\/www.pythonpool.com\/python-touch-file\/\",\"url\":\"https:\/\/www.pythonpool.com\/python-touch-file\/\",\"name\":\"Python Touch File | How To Implement Touch Files - Python Pool\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-touch-file\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-touch-file\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Python-Touch-File.webp\",\"datePublished\":\"2021-08-22T03:07:49+00:00\",\"dateModified\":\"2021-08-22T03:11:40+00:00\",\"description\":\"In this article, we are going to learn about the python touch file. With that, we will learn how to implement touch files in python.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-touch-file\/#breadcrumb\"},\"mainEntity\":[{\"@id\":\"https:\/\/www.pythonpool.com\/python-touch-file\/#faq-question-1629553255487\"},{\"@id\":\"https:\/\/www.pythonpool.com\/python-touch-file\/#faq-question-1629553500934\"}],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com\/python-touch-file\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/python-touch-file\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Python-Touch-File.webp\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Python-Touch-File.webp\",\"width\":1200,\"height\":628,\"caption\":\"Python Touch File\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com\/python-touch-file\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Touch File | How To Implement Touch Files\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pythonpool.com\/#website\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"name\":\"Python Pool\",\"description\":\"Your One-Stop Python Learning Destination\",\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pythonpool.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pythonpool.com\/#organization\",\"name\":\"Python Pool\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"contentUrl\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"width\":452,\"height\":185,\"caption\":\"Python Pool\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/pythonpool\",\"https:\/\/www.youtube.com\/c\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/83e6e22a6c461cc1a8445bb473db2f20\",\"name\":\"Priyalakshmi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8f1aadb3b77a89fe5776d41fb52aec63200d0e68e92c71cb9aafac7fb4456696?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8f1aadb3b77a89fe5776d41fb52aec63200d0e68e92c71cb9aafac7fb4456696?s=96&d=wavatar&r=g\",\"caption\":\"Priyalakshmi\"}},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.pythonpool.com\/python-touch-file\/#faq-question-1629553255487\",\"position\":1,\"url\":\"https:\/\/www.pythonpool.com\/python-touch-file\/#faq-question-1629553255487\",\"name\":\"1. How to implement touch files in python?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"We can use the pathlib module to implement the touch file in python.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.pythonpool.com\/python-touch-file\/#faq-question-1629553500934\",\"position\":2,\"url\":\"https:\/\/www.pythonpool.com\/python-touch-file\/#faq-question-1629553500934\",\"name\":\"2. How can we create a new file in python?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"We can use a path.touch() function and touch module to create new files.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python Touch File | How To Implement Touch Files - Python Pool","description":"In this article, we are going to learn about the python touch file. With that, we will learn how to implement touch files in python.","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.pythonpool.com\/python-touch-file\/","og_locale":"en_US","og_type":"article","og_title":"Python Touch File | How To Implement Touch Files","og_description":"In this article, we are going to learn about python touch files. With that, we will learn how to implement touch files in python. Simply, we can say we","og_url":"https:\/\/www.pythonpool.com\/python-touch-file\/","og_site_name":"Python Pool","article_published_time":"2021-08-22T03:07:49+00:00","article_modified_time":"2021-08-22T03:11:40+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Python-Touch-File.webp","type":"image\/webp"}],"author":"Priyalakshmi","twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Priyalakshmi","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pythonpool.com\/python-touch-file\/#article","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/python-touch-file\/"},"author":{"name":"Priyalakshmi","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/83e6e22a6c461cc1a8445bb473db2f20"},"headline":"Python Touch File | How To Implement Touch Files","datePublished":"2021-08-22T03:07:49+00:00","dateModified":"2021-08-22T03:11:40+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pythonpool.com\/python-touch-file\/"},"wordCount":873,"commentCount":1,"publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/www.pythonpool.com\/python-touch-file\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Python-Touch-File.webp","articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pythonpool.com\/python-touch-file\/#respond"]}]},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/www.pythonpool.com\/python-touch-file\/","url":"https:\/\/www.pythonpool.com\/python-touch-file\/","name":"Python Touch File | How To Implement Touch Files - Python Pool","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pythonpool.com\/python-touch-file\/#primaryimage"},"image":{"@id":"https:\/\/www.pythonpool.com\/python-touch-file\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Python-Touch-File.webp","datePublished":"2021-08-22T03:07:49+00:00","dateModified":"2021-08-22T03:11:40+00:00","description":"In this article, we are going to learn about the python touch file. With that, we will learn how to implement touch files in python.","breadcrumb":{"@id":"https:\/\/www.pythonpool.com\/python-touch-file\/#breadcrumb"},"mainEntity":[{"@id":"https:\/\/www.pythonpool.com\/python-touch-file\/#faq-question-1629553255487"},{"@id":"https:\/\/www.pythonpool.com\/python-touch-file\/#faq-question-1629553500934"}],"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pythonpool.com\/python-touch-file\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/python-touch-file\/#primaryimage","url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Python-Touch-File.webp","contentUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Python-Touch-File.webp","width":1200,"height":628,"caption":"Python Touch File"},{"@type":"BreadcrumbList","@id":"https:\/\/www.pythonpool.com\/python-touch-file\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"Python Touch File | How To Implement Touch Files"}]},{"@type":"WebSite","@id":"https:\/\/www.pythonpool.com\/#website","url":"https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Your One-Stop Python Learning Destination","publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/pythonpool","https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/83e6e22a6c461cc1a8445bb473db2f20","name":"Priyalakshmi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8f1aadb3b77a89fe5776d41fb52aec63200d0e68e92c71cb9aafac7fb4456696?s=96&d=wavatar&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8f1aadb3b77a89fe5776d41fb52aec63200d0e68e92c71cb9aafac7fb4456696?s=96&d=wavatar&r=g","caption":"Priyalakshmi"}},{"@type":"Question","@id":"https:\/\/www.pythonpool.com\/python-touch-file\/#faq-question-1629553255487","position":1,"url":"https:\/\/www.pythonpool.com\/python-touch-file\/#faq-question-1629553255487","name":"1. How to implement touch files in python?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"We can use the pathlib module to implement the touch file in python.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.pythonpool.com\/python-touch-file\/#faq-question-1629553500934","position":2,"url":"https:\/\/www.pythonpool.com\/python-touch-file\/#faq-question-1629553500934","name":"2. How can we create a new file in python?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"We can use a path.touch() function and touch module to create new files.","inLanguage":"en-US"},"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/15936","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=15936"}],"version-history":[{"count":33,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/15936\/revisions"}],"predecessor-version":[{"id":16005,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/15936\/revisions\/16005"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/15992"}],"wp:attachment":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=15936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=15936"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=15936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}