YouTip LogoYouTip

Os Getcwdu

# Python2.x Python os.getcwdu() Method [![Image 3: Python File(Files) Method](#) Python OS File/Directory Methods](#) * * * ### Overview The os.getcwdu() method is used to return a Unicode object representing the current working directory. Available on Unix and Windows systems. ### Syntax The syntax for the **getcwdu()** method is as follows: os.getcwdu() ### Parameters * None ### Return Value Returns a Unicode object representing the current working directory. ### Example The following example demonstrates the use of the getcwdu() method: #!/usr/bin/python# -*- coding: UTF-8 -*-import os, sys # Change to "/var/www/html" Directory os.chdir("/var/www/html" )# Print Current Directory print "Current working directory. : %s" % os.getcwdu()# Open "/tmp" fd = os.open( "/tmp", os.O_RDONLY )# Use os.fchdir() MethodModify Directory os.fchdir(fd)# Print Current Directory print "Current working directory. : %s" % os.getcwdu()# Close Files os.close( fd ) The output of executing the above program is: Current working directory. : /var/www/html Current working directory. : /tmp [![Image 4: Python File(Files) Method](#) Python OS File/Directory Methods](#)
← Os LchflagsOs Getcwdu β†’