Python-Ref > System interaction > Manipulating files and directories > Current directory
 
 

^^->
Klíčová slova
Moduly
Knihovní funkce

Current directory

Get and change the current directory
Expand/Shrink
Prostředí:
.
|-- filesystem1-1.py
|-- something
|   `-- example.py
|-- something_else
`-- test
    `-- test.txt
  1   import os
  2   
  3   print "current working directory           ", os.getcwd()
  4   print "current working directory (unicode) ", os.getcwdu()
  5   old_dir = os.getcwd()
  6   
  7   os.chdir( "test")
  8   print "current working directory           ", os.getcwd()
  9   
 10   os.chdir( "../something")
 11   print "current working directory           ", os.getcwd()
 12   
 13   os.chdir( old_dir)
 14   print "current working directory           ", os.getcwd()
stdout:
current working directory            /mnt/bkchem.img/projects/python-ref/_tmp
current working directory (unicode)  /mnt/bkchem.img/projects/python-ref/_tmp
current working directory            /mnt/bkchem.img/projects/python-ref/_tmp/test
current working directory            /mnt/bkchem.img/projects/python-ref/_tmp/something
current working directory            /mnt/bkchem.img/projects/python-ref/_tmp
Doba běhu: 81.0 ms