Python | os.mknod() method
OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.
os.mknod() method in Python is used to create a file system node i.e a file, device special file or named pipe with specified path name.
Syntax: os.mknod(path, mode = 0o600, device = 0, *, dir_fd = None)
Parameters:
path: A path-like object representing the file system path.
device (optional): This defines the newly created device files. The default value of this parameter is 0.
dir_fd (optional): This is a file descriptor referring to a directory.Return type: This method does not return any value.
Code: Use of os.mknod() method
# Python3 program to explain os.mknod() method # importing os module import os # importing stat module import stat # Path path = "filex.txt" # Permission to use per = 0o600 # type of node to be created node_type = stat.S_IRUSR mode = per | node_type # Create a file sytem node # with specified permission # and type using # os.mknod() method os.mknod(path, mode) print("Filesystem node is created successfully") |
File system node is created successfully
Recommended Posts:
- class method vs static method in Python
- Python | os.dup() method
- Python | set() method
- Python | next() method
- Python | os.scandir() method
- Python | cmath.log() method
- Python | os.ctermid() method
- Python | os.getppid() method
- Python | Tensorflow abs() method
- Python | cmath.exp() method
- Python | os.strerror() method
- Python | sys.getrecursionlimit() method
- Python | os.readv() method
- Python | Tensorflow log() method
- Python | os.writev() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



