Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
when repr() fails
#5
The "unicode_escape" codec is your friend:
Output:
>>> x=u'Dèjà-vu\n\t' >>> codecs.encode(x,'unicode_escape') 'D\\xe8j\\xe0-vu\\n\\t' >>> print codecs.encode(x,'unicode_escape') D\xe8j\xe0-vu\n\t
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Messages In This Thread
when repr() fails - by Skaperen - May-01-2017, 02:25 AM
RE: when repr() fails - by wavic - May-01-2017, 07:29 AM
RE: when repr() fails - by Skaperen - May-01-2017, 09:34 AM
RE: when repr() fails - by volcano63 - May-01-2017, 07:30 AM
RE: when repr() fails - by Ofnuts - May-01-2017, 03:52 PM
RE: when repr() fails - by snippsat - May-01-2017, 04:37 PM
RE: when repr() fails - by Skaperen - May-02-2017, 03:54 AM
RE: when repr() fails - by snippsat - May-02-2017, 02:32 PM
RE: when repr() fails - by Skaperen - May-03-2017, 02:48 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Repr() function Valentina 3 3,506 Aug-22-2019, 11:28 AM
Last Post: perfringo
  ascii() (repr() in py2) Skaperen 1 3,992 Jun-05-2017, 10:32 PM
Last Post: Ofnuts
  str vs repr Skaperen 9 6,173 Jun-05-2017, 01:04 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020