About the Tutorial



Download 2,85 Mb.
Pdf ko'rish
bet200/234
Sana28.05.2022
Hajmi2,85 Mb.
#614232
1   ...   196   197   198   199   200   201   202   203   ...   234
Bog'liq
python3 tutorial 060821094426

Description 
The method 
readlink()
returns a string representing the path to which the symbolic link 
points. It may return an absolute or relative pathname. 
Syntax 
Following is the syntax for readlink() method- 
os.readlink(path) 
Parameters 
path
- This is the path or symblic link for which we are going to find source of the link. 
Return Value 
This method return a string representing the path to which the symbolic link points. 
Example 


Python 3 
300 
The following example shows the usage of readlink() method. 
# !/usr/bin/python3 
import os 
src = 'd://tmp//python3' 
dst = 'd://tmp//python2' 
# This creates a symbolic link on python in tmp directory 
os.symlink(src, dst) 
# Now let us use readlink to display the source of the link. 
path = os.readlink( dst ) 
print (path) 
Let us compile and run the above program. This will create a symblic link to 
d:\tmp\python3 and later it will read the source of the symbolic link using readlink() call. 
This is an example on Windows platform and needs administrator privilege to run. Before 
running this program make sure you do not have d:\tmp\python2 already available. 
d:\tmp\python2 
os.remove() Method 
Description 
The method remove() removes the file path. If the path is a directory, OSError is raised. 
Syntax 
Following is the syntax for remove() method- 
os.remove(path) 
Parameters 
path
- This is the path, which is to be removed. 
Return Value 
This method does not return any value. 
Example 
The following example shows the usage of remove() method. 
# !/usr/bin/python3 
import os, sys 
os.chdir("d:\\tmp") 


Python 3 
301 
# listing directories 
print ("The dir is: %s" %os.listdir(os.getcwd())) 
# removing 
os.remove("test.java") 
# listing directories after removing path 
print ("The dir after removal of path : %s" %os.listdir(os.getcwd())) 
When we run above program, it produces following result- 
The dir is: ['Applicationdocs.docx', 'book.zip', 'foo.txt', 'home', 'Java 
Multiple Inheritance.htm', 'Java Multiple Inheritance_files', 'java.ppt', 
'ParallelPortViewer', 'test.java'] 
The dir after removal of path : ['Applicationdocs.docx', 'book.zip', 'foo.txt', 
'home', 'Java Multiple Inheritance.htm', 'Java Multiple Inheritance_files', 
'java.ppt', 'ParallelPortViewer'] 

Download 2,85 Mb.

Do'stlaringiz bilan baham:
1   ...   196   197   198   199   200   201   202   203   ...   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