Os Getcwdu
# Python2.x Python os.getcwdu() 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 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
[ Python OS File/Directory Methods](#)
YouTip