import urllib.request
html = urllib.request.urlopen("https://habr.com/ru/all/")
html_utf = html.read().decode('utf-8')
my_list = open("html_pars.txt", "a")
my_list.write(html_utf)
my_list.close()
Результат:
Traceback (most recent call last):
File "D:\Phyton_programms\udali.py", line 8, in
my_list.write(html_utf)
File "D:\Python37\lib\encodings\cp1251.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2265' in position 29124: character maps to
С другими произвольными страницами всё работает.