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

Python os.mknod() method

Python os.mknod() method

Python File methods Python 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/python

# -*- coding: UTF-8 -*-



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

Python File methods Python OS file/directory methods