我試圖讓Python中一個簡單的壓縮程序,但我收到此錯誤是什麼導致這個錯誤,我該如何解決它?
with open("admin.dll", "r").read() as text:
AttributeError: __exit__
爲什麼會出現這個錯誤?這是我的全部代碼
import zlib, sys, time, base64
with open("admin.txt", "r").read() as file:
print("Uncompressed: " + str(sys.getsizeof(file)))
compressed = zlib.compress(file, 9)
print("Compressed: ", end="")
print(sys.getsizeof(compressed))