About the Tutorial



Download 2,85 Mb.
Pdf ko'rish
bet170/234
Sana28.05.2022
Hajmi2,85 Mb.
#614232
1   ...   166   167   168   169   170   171   172   173   ...   234
Bog'liq
python3 tutorial 060821094426

os.unlink(path) 
Remove the file path. 
61 
os.utime(path, times) 
Set the access and modified times of the file specified by path. 
62 
os.walk(top[, topdown=True[, onerror=None[, followlinks=False]]]) 
Generate the file names in a directory tree by walking the tree either top-down 
or bottom-up. 
63 
os.write(fd, str) 
Write the string str to file descriptor fd. Return the number of bytes actually 
written. 
Let us go through the methods briefly- 
os.access() Method 
Description 


Python 3 
249 
The method access() uses the real uid/gid to test for access to path. Most operations will 
use the effective uid/gid, therefore this routine can be used in a suid/sgid environment to 
test if the invoking user has the specified access to path.It returns True if access is allowed, 
False if not. 
Syntax 
Following is the syntax for access() method- 
os.access(path, mode) 
Parameters 

path
- This is the path which would be tested for existence or any access. 

mode
- This should be F_OK to test the existence of path, or it can be the inclusive 
OR of one or more of R_OK, W_OK, and X_OK to test permissions. 
o
os.F_OK:
Value to pass as the mode parameter of access() to test the existence 
of path. 
o
os.R_OK:
Value to include in the mode parameter of access() to test the 
readability of path. 
o
os.W_OK:
Value to include in the mode parameter of access() to test the 
writability of path. 
o
os.X_OK:
Value to include in the mode parameter of access() to determine if 
path can be executed. 
Return Value 
This method returns True if access is allowed, False if not. 
Example 
The following example shows the usage of access() method. 
#!/usr/bin/python3 
import os, sys 
# Assuming /tmp/foo.txt exists and has read/write permissions. 
ret = os.access("/tmp/foo.txt", os.F_OK) 
print ("F_OK - return value %s"% ret) 
ret = os.access("/tmp/foo.txt", os.R_OK) 
print ("R_OK - return value %s"% ret) 


Python 3 
250 
ret = os.access("/tmp/foo.txt", os.W_OK) 
print ("W_OK - return value %s"% ret) 
ret = os.access("/tmp/foo.txt", os.X_OK) 
print ("X_OK - return value %s"% ret) 
When we run the above program, it produces the following result- 
F_OK - return value True 
R_OK - return value True 
W_OK - return value True 
X_OK - return value False 

Download 2,85 Mb.

Do'stlaringiz bilan baham:
1   ...   166   167   168   169   170   171   172   173   ...   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