YouTip LogoYouTip

Python3 Os Mknod

# Python3.x Python3 os.mknod() Method [![Image 3: Python3 OS File/Directory Methods](#) Python3 OS File/Directory Methods](#) * * * ### Overview The os.mknod() method is used to create a filesystem node (file, device special file, or named pipe) with the specified filename. ### Syntax The syntax for the **mknod()** method is as follows: os.mknod(filename[, mode=0600[, device=0]]) ### Parameters * **filename** -- The filesystem node to be created. * **mode** -- mode specifies the permissions for creating or using the node, combining (or bitwise OR) stat.S_IFREG, stat.S_IFCHR, stat.S_IFBLK, and stat.S_IFIFO (these constants are in the stat module). For stat.S_IFCHR and stat.S_IFBLK, the device defines the newly created device special file (possibly using os.makedev()), others are ignored. * **device** -- Optional, specifies the device for the created file. ### Return Value This method does not return a value. ### Example The following example demonstrates the use of the mknod() method: #!/usr/bin/python3import os import stat filename = '/tmp/tmpfile' mode = 0600|stat.S_IRUSR # Filesystem node with different mode os.mknod(filename, mode) The output of executing the above program is: -rw-------. 1 root root 0 Apr 30 02:38 tmpfile [![Image 4: Python3 OS File/Directory Methods](#) Python3 OS File/Directory Methods](#)
← Python3 Os OpenptyPython3 Os Mknod β†’