A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/python/touch-module-in-python/ below:

Touch module in Python - GeeksforGeeks

Touch module in Python

Last Updated : 21 Apr, 2020

In Python, the

Touch module

is used to create any file on any specified directory. The touch module is equivalent to linux command '

touch

' or to the windows' cmd command '

type null >

'.

Installation:

This module does not come built-in with Python. To install this module type the below command in the terminal.

pip install touch
Example 1:

In this example, we will create a file inside a same directory.

Python3 1==
import touch

touch.touch("success.java")
Output: Example 2:

In this example, we will create a file in a different directory. Here we create a file in "testm" folder.

Python3 1==
import touch

touch.touch("testm / success2.java")
Output: Example 3:

In this example, we will create a multiple files at the same time. For this, we need to pass the file name in a list.

Python3 1==
import touch

touch.touch(["testm / success100.java", "success10.cpp"])
Output:

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4