I try to run the following simple code in NetBeans 6.9
s = u"\u00B0 Celsius"
print u"{0}".format(s)
But I get the following error:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb0' in position 0: ordinal not in range(128)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
NetBeans’s console apparently isn’t properly set up to handle printing non-ASCII unicode strings.
In general, you should avoid printing unicode strings without explicitly encoding them (e.g.
u_str.encode(some_codec) first.In your specific case, you can probably just get away with: