반응형
    
    
    
  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 = 얻어온다는 의미가 있으니, 현재 작업 중인 폴더를 얻어온다는 의미가 되겠습니다.
반응형
    
    
    
  '프로그래밍 > Python' 카테고리의 다른 글
| [python] anaconda에 wordcloud module 설치하기 (0) | 2022.02.09 | 
|---|---|
| [Python] Konlpy - 가상환경, os.getcwd(), os.path.realpath(__file__) (0) | 2022.02.07 | 
| [python] conda, pip pandas install (0) | 2022.02.03 | 
| [Python] 현재 년, 월, 일, 시, 분, 초 문자열로 표현하기 (yyyymmddhh24miss 형태) (0) | 2022.02.03 | 
| NLTK 에러시 - Resource punkt not found 일때 (0) | 2022.01.26 | 
