About the Tutorial



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

os.getcwdu() Method 
Description 
The method getcwdu() returns a unicode object representing the current working 
directory. 
Syntax 
Following is the syntax for getcwdu() method- 
os.getcwdu() 


Python 3 
276 
Parameters 
NA 
Return Value 
This method returns a unicode object representing the current working directory. 
Example 
The following example shows the usage of getcwdu() method. 
#!/usr/bin/python3 
import os, sys 
# First go to the "/var/www/html" directory 
os.chdir("/var/www/html" ) 
# Print current working directory 
print ("Current working dir : %s" % os.getcwdu()) 
# Now open a directory "/tmp" 
fd = os.open( "/tmp", os.O_RDONLY ) 
# Use os.fchdir() method to change the dir 
os.fchdir(fd) 
# Print current working directory 
print ("Current working dir : %s" % os.getcwdu()) 
# Close opened directory. 
os.close( fd ) 
When we run the above program, it produces the following result- 
Current working dir : /var/www/html 
Current working dir : /tmp 
os.isatty() Method 
Description 


Python 3 
277 
The method isatty()returns True if the file descriptor fd is open and connected to a tty(-
like) device, else False. 
Syntax 
Following is the syntax for isatty() method- 
os.isatty( fd ) 
Parameters 
fd
- This is the file descriptor for which association needs to be checked. 
Return Value 
This method returns True if the file descriptor fd is open and connected to a tty(-like) 
device, else False. 
Example 
The following example shows the usage of isatty() method. 
#!/usr/bin/python3 
import os, sys 
# Open a file 
fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT ) 
# Write one string 
line="This is test" 
b=line.encode() 
os.write(fd, b) 
# Now use isatty() to check the file. 
ret = os.isatty(fd) 
print ("Returned value is: ", ret) 
# Close opened file 
os.close( fd ) 
When we run the above program, it produces the following result- 
Returned value is: False 


Python 3 
278 

Download 2,85 Mb.

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