개발/파이썬
python. __file__ 의미
ttoance
2021. 7. 28. 14:47
__file : 현재 파일 경로 를 알려줌
A = os.path.join(os.path.dirname(__file__), '..')
# A is the parent directory of the directory where program resides.
B = os.path.dirname(os.path.realpath(__file__))
# B is the canonicalised (?) directory where the program resides.
C = os.path.abspath(os.path.dirname(__file__))
# C is the absolute path of the directory where the program resides.
print(A)
print(B)
print(C)
./src/scripts/..
/Users/src/scripts
/Users/src/scripts
출처 : https://stackoverflow.com/questions/9271464/what-does-the-file-variable-mean-do
반응형