title: Python - Replace non-ascii character in string (»)
body: <p>I need to replace in a string the character "»" with a whitespace, but I still get an error. This is the code I use:</p>
  
  <pre><code># -*- coding: utf-8 -*-
  from bs4 import BeautifulSoup
  
  # other code
  
  soup = BeautifulSoup(data, 'lxml')
  mystring = soup.find('a').text.replace(' »','')
  </code></pre>
  
  <blockquote>
    <p>UnicodeEncodeError: 'ascii' codec can't encode character u'\xbb' in
    position 13: ordinal not in range(128)</p>
  </blockquote>
  
  <p>But If I test it with this other script:</p>
  
  <pre><code># -*- coding: utf-8 -*-
  a = "hi »"
  b = a.replace('»','') 
  </code></pre>
  
  <p>It works. Why this?</p>