Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python3 os.mknod() Method

Python3 os.mknod() Method

Python3 OS File/Directory Methods Python3 OS File/Directory Methods


Overview

The os.mknod() method creates a file system node with the specified file name (a file, device special file or named pipe).

Syntax

The **mknod()** method syntax is as follows:


os.mknod(filename[, mode=0600[, device=0]])

Parameters

Return Value

This method has no return value.

Example

The following example demonstrates the use of the mknod() method:


#!/usr/bin/python3

import os
import stat

filename = '/tmp/tmpfile'
mode = 0600|stat.S_IRUSR

# Specify different modes for filesystem nodes
os.mknod(filename, mode)

The output of the above program is:


-rw-------. 1 root   root         0 Apr 30 02:38 tmpfile

Python3 OS File/Directory Methods Python3 OS File/Directory Methods