Writing to a text file in Python from a variable, ignoring encoding problems

Writing to a file in Python is usually a simple 2-liner, which is easy to be written:

However, problems with the encoding may cause some research needed. Concerning the encoding this is a great article from the creator of StackOverflow.com. Anyway, if the encoding is passed correctly then nothing can stop us from reading the article and writing its HTML to a file, if this is our ultimate goal:

Tagged with: , , ,