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

后端 未结 29 2914
余生分开走
余生分开走 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 04:45

    Below solution worked for me, Just added

    u "String"

    (representing the string as unicode) before my string.

    result_html = result.to_html(col_space=1, index=False, justify={'right'})
    
    text = u"""
    
    
    

    Hello all,

    Here's weekly summary report. Let me know if you have any questions.

    Data Summary


    {0}

    Thanks,

    Data Team

    """.format(result_html)

提交回复
热议问题