
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How to create a filesystem node using Python?
os.mknod(path, mode=0o600, device=0, *, dir_fd=None) creates a filesystem node (file, device special file or named pipe) named path. The mode specifies both the permissions to use and the type of node to be created, being combined (bitwise OR) with one of stat.S_IFREG, stat.S_IFCHR, stat.S_IFBLK, and stat.S_IFIFO (those constants are available in stat). This function can also support paths relative to directory descriptors. It is only available on Unix. It can be used as follows:
import os import stat filename = '/tmp/tmpfile' mode = 0600|stat.S_IRUSR # filesystem node specified with different modes os.mknod(filename, mode)
Runnig the above code will create a file in /tmp directory with a name tmpfile.
- Related Articles
- How to create a directory using Python?
- Object-oriented filesystem paths in Python (pathlib)
- How to create text node in JavaFX?
- Upload from local drive to local filesystem in HTML with Filesystem API
- How to create a directory recursively using Python?
- How to create a tar file using Python?
- How to create a zip file using Python?
- How to create hardlink of a file using Python?
- How to create softlink of a file using Python?
- How to create a unique directory name using Python?
- How to create a triangle using Python for loop?
- How to create powerpoint files using Python
- How to create a unique temporary file name using Python?
- How to create a sample dataset using Python Scikit-learn?
- How to create a zip archive of a directory using Python?

Advertisements