As a French user of Python 2.7, I'm trying to properly print strings containing accents such as "é", "è", "à", etc. in the Python console.
I already know the trick of using u before the explicit value of a string, such as :
print(u'Université')
which properly prints the last character.
Now, my question is: how can I do the same for a string that is stored as a variable?
Indeed, I know that I could do the following:
mystring = u'Université'
print(mystring)
but the problem is that the value of mystring
is bound to be passed into a SQL query (using psycopg2
), and therefore I can't afford to store the u
inside the value of mystring
.
so how could I do something like
"print the unicode value of mystring
" ?