About the Tutorial



Download 2,85 Mb.
Pdf ko'rish
bet195/234
Sana28.05.2022
Hajmi2,85 Mb.
#614232
1   ...   191   192   193   194   195   196   197   198   ...   234
Bog'liq
python3 tutorial 060821094426

os.mknod() Method 
Description 
The method mknod() creates a filesystem node (file, device special file or named pipe) 
named filename. 
Syntax 
Following is the syntax for mknod() method- 
os.mknod(filename[, mode=0600[, device=0]]) 
Parameters 

filename
- This is the filesystem node to be created. 

mode
- The mode specifies both the permissions to use and the type of node to be 
created combined (bitwise OR) with one of the values stat.S_IFREG, stat.S_IFCHR, 
stat.S_IFBLK, and stat.S_IFIFO. They can be ORed base don requirement. 

device
- This is the device special file created and its optional to provide. 


Python 3 
292 
Return Value 
This method does not return any value. Available on Unix like systems. 
Example 
The following example shows the usage of mknod() method. 
# !/usr/bin/python3 
import os 
import stat 
filename = '/tmp/tmpfile' 
mode = 0600|stat.S_IRUSR 
# filesystem node specified with different modes 
os.mknod(filename, mode) 
Let us compile and run the above program, this will create a simple file in /tmp directory 
with a name tmpfile: 
-rw-------. 1 root root 0 Apr 30 02:38 tmpfile 
os.open() Method 
Description 
The method 
open()
opens the file file and set various flags according to flags and possibly 
its mode according to mode.The default mode is 0777 (octal), and the current umask value 
is first masked out. 
Syntax 
Following is the syntax for open() method: 
os.open(file, flags[, mode]); 
Parameters 

file
- File name to be opened. 

flags
- The following constants are options for the flags. They can be combined 
using the bitwise OR operator |. Some of them are not available on all platforms. 
o
os.O_RDONLY: open for reading only 
o
os.O_WRONLY: open for writing only 
o
os.O_RDWR : open for reading and writing 
o
os.O_NONBLOCK: do not block on open 


Python 3 
293 
o
os.O_APPEND: append on each write 
o
os.O_CREAT: create file if it does not exist 
o
os.O_TRUNC: truncate size to 0 
o
os.O_EXCL: error if create and file exists 
o
os.O_SHLOCK: atomically obtain a shared lock 
o
os.O_EXLOCK: atomically obtain an exclusive lock 
o
os.O_DIRECT: eliminate or reduce cache effects 
o
os.O_FSYNC : synchronous writes 
o
os.O_NOFOLLOW: do not follow symlinks 


Download 2,85 Mb.

Do'stlaringiz bilan baham:
1   ...   191   192   193   194   195   196   197   198   ...   234




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish