Jan-02-2018, 01:19 PM
Self-learning python. The following code returns UnicodeEncodeError. How should I fix it? Thanks.
import bs4, requests #---------------------------------------------------------------------------- URL = "https://learnxinyminutes.com/docs/r" #---------------------------------------------------------------------------- soup = bs4.BeautifulSoup(requests.get(URL).text, "lxml") with open( r"C:\Users\User\Desktop\Test.txt" ,"w") as oFile: oFile.write(str(soup.html)) oFile.close()UnicodeEncodeError: 'cp950' codec can't encode character '\xf8' in position 20242: illegal multibyte sequence