
zip_open 함수는 파이썬 3.x 버전부터 deprecated 되었으며, 대체 함수는 zipfile.ZipFile 클래스를 사용하는 것입니다.
zipfile.ZipFile 클래스를 사용하여 압축파일을 열 수 있습니다. 예를 들어, 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
python
import zipfile
with zipfile.ZipFile('압축파일.zip', 'r') as zip_file:
# 압축파일 내의 파일 목록을 얻을 수 있습니다.
print(zip_file.namelist())
# 압축파일 내의 파일을 읽을 수 있습니다.
with zip_file.open('파일명.txt', 'r') as file:
print(file.read())
위의 예제에서는 '압축파일.zip'이라는 압축파일을 열고, 압축파일 내의 파일 목록을 얻은 후 '파일명.txt'이라는 파일을 읽어 출력합니다.
2025-07-31 12:01