[ Python ] 파일 폴더 관리시 자주 사용하는 것

2019. 10. 31. 09:28분석 Python/구현 및 자료

728x90

도움이 되셨다면, 광고 한번만 눌러주세요.  블로그 관리에 큰 힘이 됩니다 ^^

# copy file
shutil.copyfile( from , to )

# copy folder
shutil.copytree(from , to )

# delete file or folder
shutil.rmtree(file path , ignores_erros= True)

# move file
shutil.move( from path , to path )
# 파일 존재 여부
os.path.isfile( path ) 

# config 간단 사용
config = configparser.RawConfigParser()
config.add_section("name")
config.set("name" , "tag1" , something)

# 파일 압축 
os.system(tar -cvzf name.tar file1 file2 file3)
os.system(tar -cvzf name.tar 상대경로 폴더)

# restartKernel
from IPython.display import display_html
def restartkernel() :
    display_html("<script>Jupyter.notebook.kernel.restart()</script>" , raw= True )​


 

728x90