international character sets for both str and bytesbut we must pass decoded unicode str to support the broadest range of character types in this sectionwe decompose the text story in tkinter in general to show why string types in the text widget you may or may not have noticedbut all our examples so far have been representing content as str strings--either hardcoded in scriptsor fetched and saved using simple text-mode files which assume the platform default encoding technicallythoughthe text widget allows us to insert both str and bytesfrom tkinter import text text( insert(' ''spam' insert('end' 'eggs' pack( get(' ''end''spameggs\ninsert str insert bytes "spameggsappears in text widget now fetch content inserting text as bytes might be useful for viewing arbitrary kinds of unicode textespecially if the encoding name is unknown for exampletext fetched over the internet ( attached to an email or fetched by ftpcould be in any unicode encodingstoring it in binary-mode files and displaying it as bytes in text widget may at least seem to side-step the encoding in our scripts unfortunatelythoughthe text widget returns its content as str stringsregardless of whether it was inserted as str or bytes--we get back already-decoded unicode text strings either wayt text( insert(' ''textfileline \ ' insert('end''textfileline \ ' get(' ''end''textfileline \ntextfileline \ \nt text( insert(' ' 'bytesfileline \ \ ' insert('end' 'bytesfileline \ \ ' get(' ''end''bytesfileline \ \nbytesfileline \ \ \ncontent is str for str pack(is irrelevent to get(content is str for bytes tooand \ displays as space in factwe get back str for content even if we insert both str and byteswith single \ added at the end for good measureas the first example in this section showshere' more comprehensive illustrationt text( insert(' ''textfileline \ ' insert('end''textfileline \ 'content is str for both insert(' ' 'bytesfileline \ \ 'one \ added for either type insert('end' 'bytesfileline \ \ 'pack(displays as lines get(' ''end''bytesfileline \ \ntextfileline \ntextfileline \nbytesfileline \ \ \ntext