About the Tutorial



Download 2,85 Mb.
Pdf ko'rish
bet188/234
Sana28.05.2022
Hajmi2,85 Mb.
#614232
1   ...   184   185   186   187   188   189   190   191   ...   234
Bog'liq
python3 tutorial 060821094426

os.lchown() Method 
Description 
The method lchown() changes the owner and group id of path to the numeric uid and gid. 
This function will not follow symbolic links. To leave one of the ids unchanged, set it to -
1. As of Python 3.3, this is equivalent to os.chown(path, uid, gid, follow_symlinks=False). 
Syntax 
Following is the syntax for lchown() method- 
os.lchown(path, uid, gid) 
Parameters 

path
- This is the file path for which ownership to be set. 

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

gid
- This is the Group ID to be set for the file. 


Python 3 
280 
Return Value 
This method does not return any value. 
Example 
The following example shows the usage of lchown() method. 
#!/usr/bin/python3 
import os, sys 
# Open a file 
path = "/var/www/html/foo.txt" 
fd = os.open( path, os.O_RDWR|os.O_CREAT ) 
# Close opened file 
os.close( fd ) 
# Now change the file ownership. 
# Set a file owner ID 
os.lchown( path, 500, -1) 
# Set a file group ID 
os.lchown( path, -1, 500) 
print ("Changed ownership successfully!!") 
When we run above program, it produces following result- 
Changed ownership successfully!! 
os.link() Method 
Description 
The method link() creates a hard link pointing to src named dst. This method is very useful 
to create a copy of existing file. 
Syntax 
Following is the syntax for link() method- 
os.link(src, dst) 


Python 3 
281 
Parameters 

src
- This is the source file path for which hard link would be created. 


Download 2,85 Mb.

Do'stlaringiz bilan baham:
1   ...   184   185   186   187   188   189   190   191   ...   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