python3 UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position 4400: illegal multibyte sequence

The reason for this problem (wrong \ xa0) of: 

UTF-8 encoded web page source code is: \ xc2 \ xa0, after the adoption, converted to Unicode characters: \ xa0, when displaying the time on the DOS window, converted to GBK encoded string, 
but \ xa0 this Unicode character no corresponding GBK encoded string, so the error.
Original code: 
S = the BeautifulSoup (r.text, 'html.parser') 
modified: 
. S = the BeautifulSoup (r.text, 'html.parser') encode ( 'UTF-. 8')

  

  

 

Guess you like

Origin www.cnblogs.com/lza945/p/12130984.html