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 "/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
[ Python OS File/Directory Methods](#)
YouTip