프로그래밍/Python
[python] 현재 작업 중인 경로 확인 - os.getcwd()
홍반장水_
2022. 2. 3. 12:06
반응형
os.getcwd()
import os
#작업하는 경로(위치)가 어디인지 확인
print(os.getcwd())
#절대경로
with open("D:/python/res/path_test/test.txt", "r", encoding="utf-8") as f:
data = f.read()
print(data)
#상대경로
with open("path_test/test.txt", "r", encoding="utf-8") as f:
data = f.read()
print(data)
cwd = current working directory 현재 작업 중인 디렉터리(폴더)를 의미하고,
get = 얻어온다는 의미가 있으니, 현재 작업 중인 폴더를 얻어온다는 의미가 되겠습니다.
반응형