Answer the question
In order to leave comments, you need to log in
How to read html file in python?
f = open (filename , 'r')
result = f.read()
print(result)
Traceback (most recent call last):
File "file.py", line 10, in <module>
result = f.read()
File "C:\Python34\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 10419: ch
aracter maps to <undefined>
Answer the question
In order to leave comments, you need to log in
you can see that there is an attempt to recode from your favorite cp1251 :) and see the file in UTF8...
try to open it as 'rb' and convert line by line
f = open (filemane , 'rb')
for line in f:
print(line.decode('utf8'))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question