print( get(' ''end')bytesfileline textfileline textfileline bytesfileline this makes it easy to perform text processing on content after it is fetchedwe may conduct it in terms of strregardless of which type of string was inserted howeverthis also makes it difficult to treat text data generically from unicode perspectivewe cannot save the returned str content to binary mode file as isbecause binary mode files expect bytes we must either encode to bytes manually first or open the file in text mode and rely on it to encode the str in either case we must know the unicode encoding name to applyassume the platform default sufficesfall back on guesses and hope one worksor ask the user in other wordsalthough tkinter allows us to insert and view some text of unknown encoding as bytesthe fact that it' returned as str strings means we generally need to know how to encode it anyhow on savesto satisfy python file interfaces moreoverbecause bytes inserted into text widgets must also be decodable according to the limited unicode policies of the underlying tk librarywe're generally better off decoding text to str ourselves if we wish to support unicode broadly to truly understand why that' truewe need to take brief excursion through the land of unicode unicode text in strings the reason for all this extra complexityof courseis that in world with unicodewe cannot really think of "textanymore without also asking "which kind text in general can be encoded in wide variety of unicode encoding schemes in pythonthis is always factor for str and pertains to bytes when it contains encoded text python' str unicode strings are simply strings once they are createdbut you have to take encodings into consideration when transferring them to and from files and when passing them to libraries that impose constraints on text encodings we won' cover unicode encodings it in depth here (see learning python for background detailsas well as the brief look at implications for files in )but quick review is in order to illustrate how this relates to text widgets first of allkeep in mind that ascii text data normally just works in most contextsbecause it is subset of most unicode encoding schemes data outside the ascii -bit rangethoughmay be represented differently as bytes in different encoding schemes for instancethe following must decode latin- bytes string using the latin- encoding--using the platform default or an explicitly named encoding that doesn' match the bytes will failb ' \xc \xe cb ' \xc \xe tkinter tourpart these bytes are latin- format text