Python OS 명령어

이정연·2023년 2월 24일
0

Play Data

목록 보기
2/26

import os
os.getcwd() # 현재 디렉토리
os.mkdir('[name]') # 디렉토리 생성
f = open("[file_path]", "[read write option]", encoding="[encoding option]") # 파일 열기
f.read() # 파일 내용 읽기
f.write("[text]") # 파일에 내용 쓰기
f.close() # 파일 닫기
os.chdir("[file_path]") # 디렉토리 이동
os.path.isdir("[directory_path]") # 디렉토리 유무 검사
os.listdir() # 디렉토리 내 파일들
profile
0x68656C6C6F21

0개의 댓글