SyntaxError: Non-ASCII character ‘\xa3’ in file when function returns ‘£’

Say I have a function: def NewFunction(): return ‘£’ I want to print some stuff with a pound sign in front of it and it prints an error when I try to run this program, this error message is displayed: SyntaxError: Non-ASCII character ‘\xa3’ in file ‘blah’ but no encoding declared; see http://www.python.org/peps/pep-0263.html for details … Read more

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

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 the error is not always reproducible; it sometimes works with some pages, and sometimes, it barfs by throwing a UnicodeEncodeError. I have tried just about everything I can think of, … Read more