попробуйте открыть в кодировке ютф-8
open("filename", "r", encoding="utf-8")
Не понимаю (
target = open("new_file.txt", "r", encoding="utf-8")
print(f"Содержимое файла {to_file}: ")
print(target.read())
target.close()
Выполнение:
Содержимое файла new_file.txt:
Traceback (most recent call last):
File "C:\Users\eapop\desktop\exp\ex17.py", line 29, in <module>
print(target.read())
File "C:\Users\eapop\AppData\Local\Programs\Python\Python310\lib\codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte