Python 3.6Readwrite file transcoding

I picked the code of a website. How can I write it to the txt document? how can I write it to the document? here is my code and error report

Mar.03,2021

The parameter encoding of

open is set to 'utf-8''. If you repeatedly change the code and report an error, errors= 'ignore' (or' replace')
also use the with statement to manually close the file object.
finally, 'html' is not a good variable name

.
with open('douban.txt','w',encoding='utf-8',errors='replace') as f:
    f.write(html)
print( ":",open('douban.txt','r').read() )
Menu