YouTip LogoYouTip

Os Getcwdu

# Python2.x Python os.getcwdu() Method [![Image 3: Python File Methods](#) 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 the "/var/www/html" directory os.chdir("/var/www/html" )# Print the current directoryprint "Current working directory : %s" % os.getcwdu()# Open "/tmp" fd = os.open( "/tmp", os.O_RDONLY )# Use os.fchdir() method to change directory os.fchdir(fd)# Print the current directoryprint "Current working directory : %s" % os.getcwdu()# Close the file os.close( fd ) The output of the above program is: Current working directory : /var/www/html Current working directory : /tmp [![Image 4: Python File Methods](#) Python OS File/Directory Methods](#)
← Os GetcwduOs Ftruncate β†’