I am reading gmail messages (using the code from accepted answer)
(retcode, messages) = conn.search(None, '(UNSEEN)')
if retcode == 'OK':
for num in messages[0].split(' '): # messages[0] is b'6' in my case.
It's throwing, "TypeError: a bytes-like object is required, not 'str'".
But I can see clearly its a byte object b'6'
Tried same on python shell as well and getting same error there as well. Not sure whats wrong here.
>>> b'6'.split(' ')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: a bytes-like object is required, not 'str'