following refers to mimeand the second to unicodem get_payload(decode=truedecode(to bytes via mimethen to str via unicode even without the mime decode argumentthe payload type may also differ if it is stored in different formsm message() set_payload('spam') get_payload('spamm message() set_payload( 'spam') get_payload( 'spamfetched as stored moreoverthe same hold true for the text-specific mime subclass (though as we'll see later in this sectionwe cannot pass bytes to its constructor to force binary payload)from email mime text import mimetext mimetext('line ?' ['from''lancelotm['from''lancelotm get_payload('line ? get_payload(decode= 'line ?unfortunatelythe fact that payloads might be either str or bytes today not only flies in the face of python' type-neutral mindsetit can complicate your code--scripts may need to convert in contexts that require one or the other type for instancegui libraries might allow bothbut file saves and web page content generation may be less flexible in our example programswe'll process payloads as bytes whenever possiblebut decode to str text in cases where required using the encoding information available in the header api described in the next section text payload encodingsusing header information to decode more profoundlytext in email can be even richer than implied so far--in principletext payloads of single message may be encoded in variety of different unicode schemes ( three html webpage file attachmentsall in different unicode encodingsand possibly different than the full message text' encodingalthough treating such text as binary byte strings can sometimes finesse encoding issuessaving such parts in text-mode files for opening must respect the original encoding types furtherany text processing performed on such parts will be similarly type-specific luckilythe email package both adds character-set headers when generating message text and retains character-set information for parts if it is present when parsing message text for instanceadding non-ascii text attachments simply requires passing in an encoding name--the appropriate message headers are added automatically on text generationand the character set is available directly via the get_content_charset methodemailparsing and composing mail content