기록용으로 남깁니다.
이 글을 참고했습니다.
with tarfile.open("zipped.tar.gz", "w:gz") as tar:
tar.add(f"/tmp/01.log")
sourcefile은 압축할 파일이고 zipped.tar.gz 는 생성될 압축 파일입니다.
tar cvzf zipped.tar.gz /tmp/*.log 와 유사한 결과가 생성된다고 보시면 됩니다.
간단하죠? ㅎㅎ
'IT > python' 카테고리의 다른 글
[python] 윈도우10에서 python.exe 실행 경로 확인하기 (0) | 2021.07.01 |
---|---|
[python3][vscode][pylance] operator "in" not supported for types literal and str int float 26,12 오류 끄기 (0) | 2021.06.24 |
[python3] 인스턴스의 클래스 이름 출력하기 (0) | 2021.05.03 |
[python] 소켓이 사용중인 포트 확인하기 (0) | 2021.02.09 |
[python] json.dumps object of type bytes is not json serializable (0) | 2020.12.22 |