0

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?

bha159
  • 211
  • 3
  • 14
  • Unicode strings begin with u'...try that and that should fix your problem... – deweyredman Jan 04 '17 at 21:46
  • 1
    Why have you wrapped the fourth one with extra single quotes? It would have given you the correct result if you hadn't. – Daniel Roseman Jan 04 '17 at 21:47
  • Please stop LPTHW if at all possible. First off, it teaches you Python 2, which is the outdated version of the language - essentially *all* new projects nowadays use Python 3. More importantly, its method of teaching, well, sucks. Read [this](http://sopython.com/wiki/LPTHW_Complaints) for more issues. There are many much better tutorials out there, starting with the official one on python.org. – MattDMo Jan 04 '17 at 21:49
  • For example, in Python 3, you don't have to worry about this garbage of putting `u` characters before some strings, but not others. Also, check the version of the docs you're reading - 2.5 was released in **2006**. – MattDMo Jan 04 '17 at 21:50

1 Answers1

1

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"

deweyredman
  • 1,440
  • 1
  • 9
  • 12