我的文本文件(test1.txt
)包含以下兩行:
John scored 80 in english
tim scored 75 in english
我有這個文件壓縮到test1.zip
和我想讀與下面的代碼內容:
f = 'test1.zip'
z = zipfile.ZipFile(f, "r")
zinfo = z.namelist()
for name in zinfo:
with z.open(name) as f1:
fi1 = f1.readlines()
for line in fi1:
print(line)
但我得到的結果是
b'John scored 80 in english\r\n'
b'tim scored 75 in english\r\n'
我怎麼能看這種zip文件應該給我相同的輸出,因爲這是原始文件內容的內容:
John scored 80 in english
tim scored 75 in english
你正在獲得原始輸入。 – sayan