Answers for "attributeerror: 'str' object has no attribute 'decode'"

2

attributeerror: 'str' object has no attribute 'decode'

# You are trying to decode an object that is already decoded
# You have a str, there is no need to decode from UTF-8 anymore

# Simply drop the part
	.decode('utf-8')
Posted by: Guest on March-06-2021
0

AttributeError: 'str' object has no attribute 'decode' site:stackoverflow.com

import imaplib
from email.parser import HeaderParser

conn = imaplib.IMAP4_SSL('imap.gmail.com')
conn.login('[email protected]', 'password')
conn.select()
conn.search(None, 'ALL')
data = conn.fetch('1', '(BODY[HEADER])')
header_data = data[1][0][1].decode('utf-8')
Posted by: Guest on August-02-2021

Code answers related to "attributeerror: 'str' object has no attribute 'decode'"

Python Answers by Framework

Browse Popular Code Answers by Language