在 Python 中,觸控模組用於在任何指定目錄上創建任何文件。 touch模塊相當於linux命令‘touch
'或者到windows'cmd命令' type null >
'。
安裝:
該模塊不是 Python 內置的。要安裝此模塊,請在終端中鍵入以下命令。
pip install touch
示例 1:在此示例中,我們將在同一目錄中創建一個文件。
import touch
touch.touch("success.java")
輸出:
示例 2:在此示例中,我們將在不同的目錄中創建一個文件。這裏我們在“testm”文件夾中創建一個文件。
import touch
touch.touch("testm / success2.java")
輸出:
示例 3:在此示例中,我們將同時創建多個文件。為此,我們需要在列表中傳遞文件名。
import touch
touch.touch(["testm / success100.java", "success10.cpp"])
相關用法
- Python Toolz用法及代碼示例
- Python Tuple count()用法及代碼示例
- Python Tuple index()用法及代碼示例
- Python Tuple cmp()用法及代碼示例
- Python Tuple len()用法及代碼示例
- Python Tuple max()用法及代碼示例
- Python Tuple min()用法及代碼示例
- Python Tuple tuple()用法及代碼示例
- Python Tkinter grid()用法及代碼示例
- Python TextCalendar formatmonth()用法及代碼示例
- Python TextCalendar formatyear()用法及代碼示例
- Python TextCalendar prmonth()用法及代碼示例
- Python TextCalendar pryear()用法及代碼示例
- Python Thread getName()用法及代碼示例
- Python Thread is_alive()用法及代碼示例
- Python Thread join()用法及代碼示例
- Python Thread run()用法及代碼示例
- Python Thread setName()用法及代碼示例
- Python Thread start()用法及代碼示例
- Python Timer cancel()用法及代碼示例
- Python Timer start()用法及代碼示例
- Python Tensorflow abs()用法及代碼示例
- Python Tensorflow acos()用法及代碼示例
- Python Tensorflow acosh()用法及代碼示例
- Python Tensorflow asin()用法及代碼示例
注:本文由純淨天空篩選整理自ayushmankumar7大神的英文原創作品 Touch module in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。