If I have a file test.py
that resides in some directory, how can I find out from test.py
what directory it is in? os.path.curdir
will give the current directory but not the directory where the file lives. If I invoke test.py
from some directory foo
, os.curdir
will return foo
but not the path of test.py
.
thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…