UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 20: ordinal not in range(128)

后端 未结 29 2930
余生分开走
余生分开走 2020-11-21 04:43

I\'m having problems dealing with unicode characters from text fetched from different web pages (on different sites). I am using BeautifulSoup.

The problem is that

29条回答
  •  爱一瞬间的悲伤
    2020-11-21 05:08

    Update for python 3.0 and later. Try the following in the python editor:

    locale-gen en_US.UTF-8
    export LANG=en_US.UTF-8 LANGUAGE=en_US.en
    LC_ALL=en_US.UTF-8
    

    This sets the system`s default locale encoding to the UTF-8 format.

    More can be read here at PEP 538 -- Coercing the legacy C locale to a UTF-8 based locale.

提交回复
热议问题