Python | os.mknod() method
Last Updated :
08 Sep, 2021
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
import os
import stat
path = "filex.txt"
per = 0o600
node_type = stat.S_IRUSR
mode = per | node_type
os.mknod(path, mode)
print ( "Filesystem node is created successfully" )
|
Output:
File system node is created successfully
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...