python 3 - reading a file within zipped archive places 'b' character at start of each line

Viewed 6500

In the code below, I always get a strange output that places b before every line. Just the letter b.

E.g. a sample output is like this:

[b'2017-06-01,15:19:57,']

The script itself is this:

from zipfile import ZipFile

with ZipFile('myarchive.zip','r') as myzip:
    with myzip.open('logs/logfile1.txt') as myfile:
        next(myfile)
        print(myfile.readlines())

The archive has a single folder in it called "logs" and inside logs there are several text files, each with lines below an empty first line (hence the next(myfile)

It places the b before the data, no matter which file I try to read. If there are multiple lines in a file it outputs something like this:

[b'2017-06-01,15:06:28,start session: \n', b'2017-06-01,15:06:36,stop session']

Why is it placing the pesky b there?

3 Answers
Related