About the Tutorial



Download 2,85 Mb.
Pdf ko'rish
bet173/234
Sana28.05.2022
Hajmi2,85 Mb.
#614232
1   ...   169   170   171   172   173   174   175   176   ...   234
Bog'liq
python3 tutorial 060821094426

Parameters 

path
- This is the path for which mode would be set. 

mode
- This may take one of the above mentioned values or bitwise ORed 
combinations of them. 
Return Value 
This method does not return any value. 
Note :
Although Windows supports chmod(), you can only set the file’s read-only flag with 
it (via the stat.S_IWRITE and stat.S_IREAD constants or a corresponding integer value). 
All other bits are ignored. 
Example 
The following example shows the usage of chmod() method- 
#!/usr/bin/python3 
import os, sys, stat 
# Assuming /tmp/foo.txt exists, Set a file execute by the group. 
os.chmod("/tmp/foo.txt", stat.S_IXGRP) 
# Set a file write by others. 
os.chmod("/tmp/foo.txt", stat.S_IWOTH) 
print ("Changed mode successfully!!") 


Python 3 
254 
When we run the above program, it produces the following result- 
Changed mode successfully!! 
os.chown() Method 
Description 
The method 
chown()
changes the owner and group id of path to the numeric uid and gid. 
To leave one of the ids unchanged, set it to -1.To set ownership, you would need super 
user privilege.. 
Syntax 
Following is the syntax for chown() method- 
os.chown(path, uid, gid) 
Parameters 

path
- This is the path for which owner id and group id need to be setup. 

uid
- This is Owner ID to be set for the file. 

gid
- This is Group ID to be set for the file. 
Return Value 
This method does not return any value. 
Example 
The following example shows the usage of chown() method. 
#!/usr/bin/python3 
import os, sys 
# Assuming /tmp/foo.txt exists. 
# To set owner ID 100 following has to be done. 
os.chown("/tmp/foo.txt", 100, -1) 
print ("Changed ownership successfully!!") 
When we run the above program, it produces the following result- 
Changed ownership successfully!! 


Python 3 
255 

Download 2,85 Mb.

Do'stlaringiz bilan baham:
1   ...   169   170   171   172   173   174   175   176   ...   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