How to concatenate string with unichar in python 2.7?

353 views Asked by At

How to concatenate str with unichr in python 2.7 in Jupyter IPython? As I've tried following.

string = 'blah blah'
unicode_char = unichr(169)
end_str = string + unicode_char
end_str

would throw u'blah blah\xa9' where I want to display like blah blah©.

1

There are 1 answers

0
Gui On

In Python 2 the strings are bytes and when you add a byte out of ASCII scope the string represents it as \x and a hexadecimal code. But if you call your unicode string from print it will show de unicode caracter, in your case a copyright symbol.

print end_str