Python Poplib Error
Question: This is the code

    
    
    import poplib
    from email import parser
    
    pop_conn = poplib.POP3_SSL('pop.gmail.com')
    pop_conn.user('user@gmail.com')
    pop_conn.pass_('password')
    messages = [pop_conn.retr(i) for i in range(1, len(pop_conn.list()[1]) + 1)]
    messages = ["\n".join(mssg[1]) for mssg in messages]
    messages = [parser.Parser().parsestr(mssg) for mssg in messages]
    for message in messages:
        print(message)
    

When it gets to the 8th line (`messages = ["\n".join(mssg[1]) for mssg in
messages]`)

It says this:

    
    
    TypeError: sequence item 0: expected str instance, bytes found
    

Does anyone know what i'm doing wrong?


Answer: Convert the bytes objects into string using
[`bytes.decode`](https://docs.python.org/3/library/stdtypes.html#bytes.decode):

    
    
    messages = ["\n".join(m.decode() for m in mssg[1]) for mssg in messages]
    

