Can not use \u in python

790 views Asked by At

I am newbie in python so bear with me, I am learning python from 'Learn Python The Hard Way', I learned about escape sequences but I am not able to use \u. I have tried print "\U0001F47E" , print "U\U0001F47E" , print "U'\U001F47E'", print 'u"\U0001F47E"' but all print the string within quotes as it is, I have tried print "\x56" and other with \x they all are working fine. I also looked at https://docs.python.org/2.5/ref/strings.html but I did not find anything that can help me.

So please tell what I am doing wrong?

1

There are 1 answers

1
deweyredman On BEST ANSWER

Unicode strings begin with "u"...try that and that should fix your problem.

you were on the right track here:print 'u"\U0001F47E"'

except you don't need the single quotes. so... print u"\U0001F47E"