import os
# curdir attribute lists the current directory
# which is always '.' .... which means...right here
print os.curdir
#output:
# .
# to see what the path to the curdir
print os.path.abspath(os.path.curdir)
#output
# C:\Documents and Settings\steve\My Documents\python
# and then to see what files are in the curdir
print os.listdir(os.curdir)
#or
print os.listdir(os.path.abspath(os.path.curdir))
# output for either listdir
#['colormaker.py', 'createThumbnail.py', 'strFunctions.py', 'pycolor.py']
A python example based blog that shows how to accomplish python goals and how to correct python errors.
Tuesday, September 22, 2009
python - os module and working directory
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment