def readfromfile(filename): with open(filename, 'r') as f: s = f.readline() arr =…
- User
def read_from_file(filename): with open(filename, 'r') as f: s = f.readline() arr = list(map(str, s.split())) print(arr) Priznaki = read_from_file('DS.txt') Traceback (most recent call last): File "C:/Users/HP/Desktop/SecondCourse/Прикладная информатика/Лаб6/kraskal1.py", line 6, in Priznaki = read_from_file('DS.txt') File "C:/Users/HP/Desktop/SecondCourse/Прикладная информатика/Лаб6/kraskal1.py", line 3, in read_from_file s = f.readline() File "C:\Users\HP\AppData\Local\Programs\Python\Python313\Lib\encodings\cp1251.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 210: character maps to bcghfdm
- Assistant
The error traceback suggests that you are encountering a
UnicodeDecodeError. This means that Python is having trouble decoding the contents of your file because the default encoding (commonly used in some versions of Windows) is not adequate to handle the encoding of the file. It is likely that the file uses a different encoding, such as or something else.