250x250
반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- TensorFlow
- 유튜브 API
- gather_nd
- XAI
- login crawling
- 상관관계
- session 유지
- GCP
- Airflow
- API
- hadoop
- top_k
- Retry
- 공분산
- flask
- API Gateway
- requests
- correlation
- Counterfactual Explanations
- integrated gradient
- GenericGBQException
- youtube data
- spark udf
- chatGPT
- tensorflow text
- grad-cam
- airflow subdag
- UDF
- subdag
- BigQuery
Archives
- Today
- Total
데이터과학 삼학년
OS 모듈 정리 본문
반응형
python을 사용하여 작업을 진행할때 os 모듈을 통해 작업의 디렉토리 설정, 파일 path등을 설정 관리할 수 있다.
파일을 참조하는 코드의 경우, os 모듈은 필수적이다.
getcwd(), listdir(), mkdir(), chdir(path)
## 현재 파일/폴더 경로
os.getcwd()
-> '/home/bdh/OS_module'
## 현재 파일 경로에 있는 dir 리스트
os.listdir('.')
-> ['os module.ipynb', '.ipynb_checkpoints']
## 현재 경로에 dir 생성
os.mkdir('test')
## 작업 경로 변경
os.chdir('test')
rename(src, dst), name
## 파일 이름 변경(src를 dst로 이름을 변경하거나 이동) os.rename(src, dst)
rename('text.txt', 'renamed.txt')
## 파이썬이 실행되는 운영체제의 이름
os.name
-> 'posix'
getpid(), getenv(varname[, value]), putenv(varname, value)
## 현재 실행되고 있는 프로세스 id
os.getpid()
-> 3169
## 환경 변수의 값을 얻어 옵니다. 다만 해당 환경 변수가 없을 경우에는 인자로 전달된 <value>값을 반환합니다. value가 생략되고 해당 환경 변수가 없으면 None을 반환 합니다.
os.getenv('homepath')
## 환경변수 설정 os.putenv(varname, value)
os.putenv('test', '\\tmp\\test')
https://docs.python.org/ko/3/library/os.html?highlight=write
https://devanix.tistory.com/304
728x90
반응형
LIST
'Python' 카테고리의 다른 글
property (getter, setter) (0) | 2020.03.23 |
---|---|
모듈, 패키지 개념 정리 (if __name__=='__main__': 쓰는 이유) (4) | 2020.03.23 |
Decorator (데커레이터) (0) | 2020.01.26 |
Closer (클로저) (0) | 2020.01.12 |
Abstract method (추상 메서드) (0) | 2020.01.10 |
Comments