Blog Full Notice
back to main page
파일 실행시킬 때 로그에 .py 파일도 같이 저장하는 방법
motivation:
import os
import shutil
# 결과 파일이 저장될 경로를 설정
pth_rst_exp = os.path.join(pth_rst, args.compare) # pth_rst_exp 여기가 저장하고 싶은 폴더명
os.makedirs(pth_rst_exp, exist_ok=True)
# 현재 실행 중인 python 파일의 경로를 찾기
current_script = os.path.realpath(__file__)
# 복사본을 저장할 경로 설정
destination = os.path.join(pth_rst_exp, 'train_copy.py')
# 파일 복사
shutil.copy(current_script, destination)
댓글남기기