0

I am new to reading textfiles. i run the following code:

with open('sometext.txt', 'rb') as xy: txt = xy.read().decode('utf-8')

i get this error:

UnicodeEncodeError: 'latin-1' codec can't encode character '\u201e' in position 137: ordinal not in range(256)

i already tried to play around with encoding and decoding. but without success. the text in the file is german, may the error depends on that. thanks for help

Alex
  • 999
  • 1
  • 14
  • 31
  • This question is already answered [here](https://stackoverflow.com/questions/8290206/python-unicodeencodeerror-latin-1-codec-cant-encode-character) – CopyrightC Feb 19 '21 at 10:07
  • 1
    Does this answer your question? [Python : UnicodeEncodeError: 'latin-1' codec can't encode character](https://stackoverflow.com/questions/8290206/python-unicodeencodeerror-latin-1-codec-cant-encode-character) – Jeroen Steenbeeke Feb 19 '21 at 11:54

0 Answers0