About the Tutorial


Syntax  Following is the syntax for ttyname() method-  os.ttyname(fd)  Parameters



Download 2,85 Mb.
Pdf ko'rish
bet210/234
Sana28.05.2022
Hajmi2,85 Mb.
#614232
1   ...   206   207   208   209   210   211   212   213   ...   234
Bog'liq
python3 tutorial 060821094426

Syntax 
Following is the syntax for ttyname() method- 
os.ttyname(fd) 
Parameters 
fd
- This is the file descriptor. 
Return Value 
This method returns a string which specifies the terminal device. Available on Unix like 
Systems. 
Example 
The following example shows the usage of ttyname() method. 
# !/usr/bin/python33 
import os, sys 
# Showing current directory
print ("Current working dir :%s" %os.getcwd()) 
# Changing dir to /dev/tty 
fd = os.open("/dev/tty",os.O_RDONLY) 
p = os.ttyname(fd) 
print ("the terminal device associated is: ") 
print p 
print ("done!!") 
os.close(fd) 
print ("Closed the file successfully!!") 
When we run the above program, it produces the following result- 
Current working dir is :/tmp 
the terminal device associated is: 
/dev/tty 


Python 3 
317 
done!! 
Closed the file successfully!! 
os.unlink() Method 
Description 
The method 
unlink()
removes (deletes) the file path. If the path is a directory, OSError 
is raised. This function is identical to the remove() mehod; the unlink name is its traditional 
Unix name. 
Syntax 
Following is the syntax for unlink() method- 
os.unlink(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 unlink() method. 
# !/usr/bin/python3 
import os, sys 
os.chdir("d:\\tmp") 
# listing directories 
print ("The dir is: %s" %os.listdir(os.getcwd())) 
os.unlink("foo.txt") 
# listing directories after removing path 
print ("The dir after removal of path : %s" %os.listdir(os.getcwd())) 
When we run the above program, it produces the following result- 
The dir is: ['Applicationdocs.docx', 'book.zip', 'foo.txt', 'Java Multiple 
Inheritance.htm', 'Java Multiple Inheritance_files', 'java.ppt', 'python2'] 
The dir after removal of path : ['Applicationdocs.docx', 'book.zip', 'Java 
Multiple Inheritance.htm', 'Java Multiple Inheritance_files', 'java.ppt', 
'python2'] 


Python 3 
318 

Download 2,85 Mb.

Do'stlaringiz bilan baham:
1   ...   206   207   208   209   210   211   212   213   ...   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